r4728 remove no-op line
[racktables] / gateways / netcat
1 #!/usr/bin/perl
2
3 use strict;
4 use Getopt::Long;
5
6 # fetch command-line parameters
7 my $op_help;
8 my $op_port = 23;
9 my $op_ncbin = '/usr/bin/nc';
10 my $op_connect_timeout = 30;
11 GetOptions (
12 'h' => \$op_help,
13 'port|p:i' => \$op_port,
14 'ncbin|b:s' => \$op_ncbin,
15 'connect-timeout|w:i' => \$op_connect_timeout,
16 );
17 if ($op_help) {
18 &display_help;
19 exit;
20 }
21 my $op_host = $ARGV[0];
22 defined $op_host or die "ERROR: missing hostname argument (-h for help)";
23
24 sub display_help {
25 print <<END;
26 netcat wrapper script for RackTables
27 Usage:
28 $0 <hostname> [-b </path/to/netcat/binary>] [-p <port>] [--connect-timeout=<seconds>]
29 -p, --port TCP port number to connect to (defaults to 23)
30 -b, --ncbin Full path to netcat binary (defaults to $op_ncbin)
31 -w, --connect-timeout netcat timeout (defaults to $op_connect_timeout)
32
33 END
34 }
35
36 my @params;
37 push @params, '-w', $op_connect_timeout;
38
39 exec ($op_ncbin, $op_host, $op_port, @params) or die "cannot exec $op_ncbin: $!";