2012-11-13 22:03:57 +00:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
# IBM(c) 2012 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
|
|
|
|
BEGIN
|
|
|
|
{
|
|
|
|
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
|
|
|
|
}
|
|
|
|
|
|
|
|
use lib "$::XCATROOT/lib/perl";
|
|
|
|
use Getopt::Long;
|
|
|
|
use xCAT::RShellAPI;
|
|
|
|
|
|
|
|
Getopt::Long::Configure("require_order");
|
|
|
|
Getopt::Long::Configure("no_pass_through");
|
|
|
|
|
|
|
|
my $username;
|
|
|
|
my $passwd;
|
|
|
|
my $help;
|
2012-11-29 21:52:15 +00:00
|
|
|
my $verbose;
|
2012-11-13 22:03:57 +00:00
|
|
|
|
|
|
|
if (!GetOptions(
|
|
|
|
'l|loginname=s' => \$username,
|
|
|
|
'p|password=s' => \$passwd,
|
|
|
|
'h|help' => \$help,
|
2012-11-29 21:52:15 +00:00
|
|
|
'v|verbose'=> \$verbose,
|
2012-11-13 22:03:57 +00:00
|
|
|
) || $help || scalar(@ARGV)<2 ) {
|
2012-11-29 21:52:15 +00:00
|
|
|
print "Usage: rshell_api [-v] [-l <user>] [-p <passwrd>] <node> <command>\n";
|
2012-11-13 22:03:57 +00:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $node = $ARGV[0];
|
|
|
|
|
2012-11-29 21:52:15 +00:00
|
|
|
my $output =xCAT::RShellAPI::run_remote_shell_api($node, $username, $passwd, $verbose, @ARGV[1 .. $#ARGV]);
|
2012-11-16 17:21:35 +00:00
|
|
|
my $rc=0;
|
|
|
|
my $data;
|
|
|
|
if ($output && (@$output > 1)) {
|
|
|
|
$rc=$output->[0];
|
|
|
|
$data=$output->[1];
|
|
|
|
}
|
2012-11-13 22:03:57 +00:00
|
|
|
|
2012-11-16 17:21:35 +00:00
|
|
|
print "$data";
|
|
|
|
exit $rc;
|