From a9af8d12cb29581ae44803127da4a675e59ae04d Mon Sep 17 00:00:00 2001 From: lissav Date: Thu, 25 Aug 2011 12:52:19 +0000 Subject: [PATCH] improvements to runcmd streaming git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@10365 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/Utils.pm | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index ea6572892..f19623c7f 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -1016,6 +1016,7 @@ sub runcmd3 { #a proper runcmd that indpendently returns stdout, stderr, pid and Example: my $outref = xCAT::Utils->runcmd($cmd, -2, 1); + $::CALLBACK= your callback (required for streaming from plugins) my $outref = xCAT::Utils->runcmd($cmd,-2, 1, 1); streaming Comments: @@ -1079,14 +1080,21 @@ sub runcmd my $done = sysread $_,$line,180; if ($done) { if ($_ eq $cmdout) { + if ($::CALLBACK){ $rsp->{data}->[0] = $line; xCAT::MsgUtils->message("I", $rsp, $::CALLBACK, 0); - $output .= $line; + } else { + xCAT::MsgUtils->message("I", "$line\n"); + } + $output .= $line; } else { + if ($::CALLBACK){ $rsp->{data}->[0] = $line; xCAT::MsgUtils->message("I", $rsp, $::CALLBACK, 0); - #push @$outreferr,$line; - $errout .= $line; + } else { + xCAT::MsgUtils->message("I", "$line\n"); + } + $errout .= $line; } } else { $cmdsel->remove($_);