Commit dbc826d4 authored by dscho's avatar dscho

use Getopt

parent ba10bcee
#!/usr/bin/perl #!/usr/bin/perl
use Getopt::Long;
use nacro; use nacro;
# TODO: take options # TODO: take options
...@@ -9,6 +10,37 @@ $server="localhost"; ...@@ -9,6 +10,37 @@ $server="localhost";
$port=5900; $port=5900;
$listen_port=5923; $listen_port=5923;
if(!GetOptions(
"script:s" => \$output,
"listen:i" => \$listen_port
) || $#ARGV!=0) {
print STDERR "Usage: $ARGV0 [--script output_name] [--listen listen_port] server[:port]\n";
exit 2;
}
$output=~s/\.pl$//;
$server=$ARGV[0];
if($server=~/^(.*):(\d+)$/) {
$server=$1;
$port=$2;
if($2<100) {
$port+=5900;
}
}
if($listen_port<100) {
$listen_port+=5900;
}
# do not overwrite script
if(stat("$output.pl")) {
print STDERR "Will not overwrite $output.pl\n";
exit 2;
}
# start connection # start connection
$vnc=nacro::initvnc($server,$port,$listen_port); $vnc=nacro::initvnc($server,$port,$listen_port);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment