log the stdout & stderr of each postscript to the local log file on each compute node

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@5728 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
wuzhy 2010-04-09 06:12:40 +00:00
parent f0c2b69de1
commit 94f6e16af6
2 changed files with 13 additions and 4 deletions

View File

@ -259,17 +259,20 @@ if (-f $scriptname)
`echo "
# subroutine used to run postscripts
run_ps () {
logdir=\\"/var/log/xcat\\"
\\\`mkdir -p \\\$logdir\\\`
logfile=\\"/var/log/xcat/xcat.log\\"
if [[ -f \\\$1 ]]; then
echo \\"Running postscript: \\\$1\\"
print $::LOG_FILE "$::sdate xcataixpost: Running postscript: $1\n";
OUTPUT=\\\`./\\\$1 2>&1\\\`
if [[ -n \\\$OUTPUT ]]; then
echo \\"\\\$OUTPUT\\"
print $::LOG_FILE "$::sdate xcataixpost: output=$output\n";
echo \\"Postscript \\\$1: \\\$OUTPUT\\" >> \\\$logfile
fi
else
echo \\"Postscript \\\$1 does NOT exist.\\"
print $::LOG_FILE "$::sdate xcataixpost: $1 does NOT exist.\n";
echo \\"Postscript \\\$1 does NOT exist.\\" >> \\\$logfile
fi
}
# subroutine end

View File

@ -308,15 +308,21 @@ fi
TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript`
echo "
# subroutine used to run postscripts
run_ps () {
run_ps () {
logdir=\"var/log/xcat\"
\`mkdir -p \$logdir\`
logfile=\"var/log/xcat/xcat.log\"
if [[ -f \$1 ]]; then
echo \"Running postscript: \$1\"
OUTPUT=\`./\$1 2>&1\`
if [[ -n \$OUTPUT ]]; then
echo \"\$OUTPUT\"
echo \"Postscript \$1: $OUTPUT\"\ >> \$logfile
fi
else
echo \"Postscript \$1 does NOT exist.\"
echo \"Postscript \$1 does NOT exist.\" >> \$logfile
fi
}
# subroutine end