Hi all,
I have the following script which I use to chek the output of jobs submitted to a PBS server.
#!/bin/sh
#
#recover.sh
#
check()
{
echo "Do you want to proceed?"
read answer
if [ "${answer}" == "y" ] ; then
echo "... proceeding ..."
else
echo "--------- Aborting -----------"
exit 1
fi
}
project=$1
echo "Make a recovery def for project: ${project}"
echo "First, look at the project summary."
check
echo "get project summary --project=${project}"
get project summary --project=${project}
echo "Now get the recovery dims."
check
echo "generate strict recovery project --printQuery --project=${project}"
dims=`generate strict recovery project --printQuery --project=${project}`
echo "$dims"
echo "Translate these dims."
check
echo "translate --dims=\"${dims}\""
translate --dims="${dims}"
echo "Create the recovery definition."
check
echo "create definition --group=dzero --defName=recovery_project_${project} --dims=\"${dims}\""
create definition --group=dzero --defName=recovery_project_${project} --dims="${dims}"
echo "Now check the definition."
#check
echo "translate --summaryOnly --dims=\"__set__ recovery_project_${project}\""
translate --summaryOnly --dims="__set__ recovery_project_${project}"
echo "DONE!"
echo "Recovery def: recovery_project_${project}"
Since it needs to be fed with the job id name, and since I have 100s of these failed jobs, I made another script (I am not good at scripting yet) I made this other script:
#! /bin/sh
for JOBID in `cat jobs.txt`
do
./recover.sh $JOBID
done
where jobs.txt has all the job ids.
Now this is like a semi-automatic script, so to speak, because I have to answer these questions manually through the keyboard.
Most of the time the answer is yes, unless that output of the second check
get project summary --project=${project}
contains the string "NO FILES TO RECOVER" in this case it should be given a return (enter hit) so that it aborts the current JOBID and falls to the next JOBID in the jobs.txt (which has all the jobs names one jobs id per line)
How may I achieve an automatic yes unless the output contains NO FILES TO RECOVER?
Thanks in advance,