diff --git a/xCAT-client/bin/xcatDBcmds b/xCAT-client/bin/xcatDBcmds index e3f595c06..4020db879 100755 --- a/xCAT-client/bin/xcatDBcmds +++ b/xCAT-client/bin/xcatDBcmds @@ -54,7 +54,7 @@ else $cmdref->{cwd}->[0] = cwd(); # get info from files piped in as stdin my $data; -if (($^O =~ /^linux/i) && ($ENV{'SHELL'} =~ /\/ksh$/)) +if ( (($^O =~ /^linux/i) && ($ENV{'SHELL'} =~ /\/ksh$/)) || !defined($ENV{'TERM'}) ) { my $rin=""; vec($rin,fileno(STDIN),1)=1; diff --git a/xCAT-client/bin/xcatclient b/xCAT-client/bin/xcatclient index 8db1d2c7a..3f5c3c0ac 100755 --- a/xCAT-client/bin/xcatclient +++ b/xCAT-client/bin/xcatclient @@ -23,11 +23,28 @@ if ($bname =~ /xcatclient/) { $cmdref->{command}->[0]=shift @ARGV; } # xcatclie else { $cmdref->{command}->[0] = $bname; } # the cmd was sym linked to xcatclient $cmdref->{cwd}->[0] = cwd(); -if (-p STDIN) { - my $data; - while ( ) { $data.=$_; } - $cmdref->{stdin}->[0]=$data; + +# allows our plugins to get the stdin of the cmd that invoked the plugin +if ( (($^O =~ /^linux/i) && ($ENV{'SHELL'} =~ /\/ksh$/)) || !defined($ENV{'TERM +'}) ) +{ + my $rin=""; + vec($rin,fileno(STDIN),1)=1; + my $nfound=select($rout=$rin,"","",1); + if ($nfound) + { + while ( ) { $data.=$_; } + $cmdref->{stdin}->[0]=$data; + } } +else +{ + if (-p STDIN) { + while ( ) { $data.=$_; } + $cmdref->{stdin}->[0]=$data; + } +} + my $arg; my @tmpargv = @ARGV; diff --git a/xCAT-client/bin/xcatclientnnr b/xCAT-client/bin/xcatclientnnr index 4462369b1..df1165117 100755 --- a/xCAT-client/bin/xcatclientnnr +++ b/xCAT-client/bin/xcatclientnnr @@ -17,12 +17,26 @@ 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(); - -if (-p STDIN) { - my $data; - while ( ) { $data.=$_; } - $cmdref->{stdin}->[0]=$data; +# allows our plugins to get the stdin of the cmd that invoked the plugin +if ( (($^O =~ /^linux/i) && ($ENV{'SHELL'} =~ /\/ksh$/)) || !defined($ENV{'TERM'}) ) +{ + my $rin=""; + vec($rin,fileno(STDIN),1)=1; + my $nfound=select($rout=$rin,"","",1); + if ($nfound) + { + while ( ) { $data.=$_; } + $cmdref->{stdin}->[0]=$data; + } } +else +{ + if (-p STDIN) { + while ( ) { $data.=$_; } + $cmdref->{stdin}->[0]=$data; + } +} + push (@{$cmdref->{arg}}, @ARGV); foreach (keys %ENV) {