From 000f7551110424c441f91dfb4be011db8ef58617 Mon Sep 17 00:00:00 2001 From: lissav Date: Fri, 31 Oct 2008 19:56:18 +0000 Subject: [PATCH] fix usage and arg handling per defect 2027948 git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@2444 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-client/bin/prsync | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/xCAT-client/bin/prsync b/xCAT-client/bin/prsync index ebfcb523f..931c3dd18 100755 --- a/xCAT-client/bin/prsync +++ b/xCAT-client/bin/prsync @@ -19,9 +19,10 @@ use Getopt::Long; use POSIX qw(:signal_h :errno_h :sys_wait_h); my $interface; Getopt::Long::Configure("require_order"); -GetOptions( - "interface=s" => \$interface, - ); +Getopt::Long::Configure("posix_default"); +Getopt::Long::Configure("no_gnu_compat"); +Getopt::Long::Configure("bundling"); + my %nodehdl; my $xcathost='localhost:3001'; if ($ENV{XCATHOST}) { @@ -29,9 +30,29 @@ if ($ENV{XCATHOST}) { } my $pshmaxp = 64; #TODO: should this be server dictated or local conf? -unless (@ARGV) { - print "Usage: pscp [-i :\n"; +if (!(@ARGV)) { + &usage; + exit(1); + } +if (!GetOptions( + 'h|help' => \$help, + 'v|version' => \$version, + 'i|interface=s' => \$interface)) +{ + &usage; + exit(1); +} +if ($help) { + &usage; + exit(0); +} +if ($version) { + my $version = xCAT::Utils->Version(); + print "$version \n"; + exit(0); +} + (my $noderange,my $destloc) = split(/:/,$ARGV[1]); my $client = IO::Socket::SSL->new( PeerAddr=>$xcathost, @@ -132,3 +153,9 @@ sub scpnode { my $dest = shift; open($$out,"rsync -az $file $node:$dest 2>&1 |"); } +sub usage { + print "Usage: prsync filename [filename ...] noderange:destinationdirectory\n"; + print " prsync [rsync-opts] [filename filename ...] [directory directory ...]\n"; + print " noderange:destinationdirectory\n"; + print " prsync {-h|--help|-v|--version}\n"; +}