From c9957417691f248d357d9abd78c715c3623efefc Mon Sep 17 00:00:00 2001 From: daniceexi Date: Mon, 30 Aug 2010 07:57:46 +0000 Subject: [PATCH] defect 3055837: make the runcmd subroutine has an argument to decide whether to output the error message when executing a command string git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@7302 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT/postscripts/xcataixpost | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/xCAT/postscripts/xcataixpost b/xCAT/postscripts/xcataixpost index 85fdb9b07..582cbb68a 100755 --- a/xCAT/postscripts/xcataixpost +++ b/xCAT/postscripts/xcataixpost @@ -313,7 +313,7 @@ if (@ARGV<1) { } } else { #called by updatenode, infrom user it is done - print "returned from postscript"; + print "returned from postscript\n"; print $::LOG_FILE "$::sdate xcataixpost: returned from postscript.\n"; } @@ -340,7 +340,7 @@ $nodesetstat =~ s/'|"//g; if ($nodesetstat eq 'standalone') { # see if it is already there my $lsicmd = "/usr/sbin/lsitab xcat > /dev/null 2>&1"; - if (&runcmd($lsicmd) == 0) { + if (&runcmd($lsicmd, 0) == 0) { # ok - remove the entry my $rmitab_cmd = 'rmitab "xcat" > /dev/null 2>&1'; if (&runcmd($rmitab_cmd) != 0) { @@ -478,11 +478,20 @@ sub updateflag { ##################################################### # # run the command +# the first argument is the command string +# the second argument is the log flag, +# 0 - does NOT log error message +# 1 - log error message +# if it is not specified, it equals to 1 # ##################################################### sub runcmd { - my ($cmd) = @_; + my ($cmd, $logerr) = @_; + + if(! defined($logerr)) { + $logerr = 1; + } my $rc=0; $cmd .= ' 2>&1' ; $::outref = []; @@ -490,10 +499,10 @@ sub runcmd if ($?) { $rc = $? >> 8; - if ($rc > 0) + if ($rc > 0 && $logerr) { - print "$::sdate xcataixpost: $::outref\n"; - print $::LOG_FILE "$::sdate xcataixpost: $::outref\n"; + print "$::sdate xcataixpost: run: $cmd - $::outref\n"; + print $::LOG_FILE "$::sdate xcataixpost: run: $cmd - $::outref\n"; } } return $rc;