2007-10-26 22:44:33 +00:00
#!/usr/bin/env perl
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
2008-02-14 14:25:49 +00:00
# Used as a standard client cmd that can be used for xcat cmds that do not have
# noderange as an argument. See xcatclient for additional documentation.
# To use this, sym link your cmd name to this script.
BEGIN { $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr'; }
use lib "$::XCATROOT/lib/perl";
use Cwd;
2007-10-26 22:44:33 +00:00
use File::Basename;
2008-02-14 14:25:49 +00:00
use xCAT::Client;
2011-12-12 19:54:30 +00:00
use strict;
2007-10-26 22:44:33 +00:00
my $bname = basename($0);
2008-02-14 14:25:49 +00:00
my $cmdref;
if ($bname =~ /xcatclientnnr/) { $cmdref->{command}->[0]=shift @ARGV; } # xcatclientnnr was invoked directly and the 1st arg is cmd name that is used to locate the plugin
else { $cmdref->{command}->[0] = $bname; } # the cmd was sym linked to xcatclientnnr
$cmdref->{cwd}->[0] = cwd();
2011-12-12 19:54:30 +00:00
my $data;
2011-12-12 16:25:53 +00:00
# allows our plugins to get the stdin of the cmd that invoked the plugin
if ( (($^O =~ /^linux/i) && ($ENV{'SHELL'} =~ /\/ksh$/)) || !defined($ENV{'TERM'}) )
{
2011-12-12 19:54:30 +00:00
my $rout;
2011-12-12 16:25:53 +00:00
my $rin="";
vec($rin,fileno(STDIN),1)=1;
my $nfound=select($rout=$rin,"","",1);
if ($nfound)
{
while ( <STDIN> ) { $data.=$_; }
$cmdref->{stdin}->[0]=$data;
}
2007-10-26 22:44:33 +00:00
}
2011-12-12 16:25:53 +00:00
else
{
if (-p STDIN) {
while ( <STDIN> ) { $data.=$_; }
$cmdref->{stdin}->[0]=$data;
}
}
2007-10-26 22:44:33 +00:00
2008-02-14 14:25:49 +00:00
push (@{$cmdref->{arg}}, @ARGV);
2010-03-02 21:54:37 +00:00
foreach (keys %ENV) {
if (/^XCAT_/) {
$cmdref->{environment}->{$_} = $ENV{$_};
}
}
2008-02-14 14:25:49 +00:00
xCAT::Client::submit_request($cmdref,\&xCAT::Client::handle_response);
exit $xCAT::Client::EXITCODE;
2007-10-26 22:44:33 +00:00