Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

at command hanging as part of nested if statement

Status
Not open for further replies.

hubud

Instructor
Oct 18, 2002
123
GB
Not sure why but the following (large code block) hangs on the final at command. Most of the processing is irrelevant to the problem and I've tried to remove as much as possible to improve legibility.

Code as follows:

#!/bin/ksh


date="Mon"
time="13"
prod=/apps/prod
SrcFiles=/apps/informat5/informatica/PowerCenter/SrcFiles
#Function to write to current_schedule.txt

function atlist_f {

atlist1="echo \"Job_Id: EMS Light Date: \`date\`\" >> $SrcFiles/current_schedule.txt"
atlist2="echo \`at -l\` >> $SrcFiles/current_schedule.txt"
eval $atlist1
eval $atlist2
rm -f $marker
}


if [ $date = "Fri" ]
then


#declare directory variables
prod=/apps/prod
test=/apps/dev
SrcFilestestinf=/apps/informatica/powercenter/SrcFiles
buzzsaw=buzzsaw.cisco.com:/fs/ftp/home/mbis/pub/techmar
buzzsawselfserve=buzzsaw.cisco.com:/fs/ftp/home/mbis/pub/selfserve


scripts=/apps/prod/ems/scripts
namelist=$scripts/names_k2k.txt
marker=$scripts/temp/k2k_test_marker_file
filename=$scripts/self_serve_echo
counter=$scripts/temp/ems_light_counter

#Create a file containing possible files not wanting to be overwritten
ls $SrcFiles/SELF_SERVE*.txt > $marker


today=`date '+20%y%m%d'`


if [ -s $marker ]
then
if [ $time -ge 9 -a $time -le 17 ]
then
echo "Schedule for 1 hours time. Between 9 and 1700 hours"
atlist_f
elif [ $time = 18 ]
then

echo "Email: second to last attempt. Friday. 1 more try then next friday"
atlist_f

elif [ $time -ge 19 ]
then

echo "Re-schedule for Monday due to files in the SrcFiles directory being present"
atlist_f

fi
else

cd $SrcFilesprodinf

echo "Copy would be made at this point. No files in target directory. file in Source directory"

if [ "$?" = "1" ]
then
echo "Copy failed for some reason. Details written to log. Retry in 1 hour"
atlist_f
else

echo "Success ful copy made"
at 09:00 friday < $filename > /dev/null 2>&1
atlist_f

fi

fi
else #####PROBLEM WITH HANGING############
echo &quot;Day not friday, schedule for friday&quot;
at 09:00 friday < $filename > /dev/null 2>&1
atlist_f

fi

------------

I have seen this happen before and can't see why the final at command does not run like all the others do.

If you wizkids can see the problem, I would love some advice on it.




cheers

simmo
 
> at 09:00 friday < $filename > /dev/null 2>&1
To see what happens, change the output redirection

Hope This Help
PH.
 
What is the error message ?
Execute your script with the -x option :
sh -x script
or add the following statement in your script :
set -x



Why do you use eval in your atlist_f function ?
Try

function atlist_f {
echo &quot;Job_Id: EMS Light Date: `date`&quot; >> $SrcFiles/current_schedule.txt
at -l >> $SrcFiles/current_schedule.txt
rm -f $marker
}


Jean Pierre.
 
The error that i'm getting is that it hangs and doesn't exit from the script.

Not sure what you mean phv? are you including the > at the beginning of the line for a reason or is that the prompt.
I have tried doing the thing manually at the command line and it runs fine. Problems in the script.

With regards to the eval in the function, i've used it elsewhere and it worked so it was a copy and paste thing. Does work though.

cheers

simmo
 
Replace this lines:
Code:
 at 09:00 friday < $filename > /dev/null 2>&1
with something like this:
Code:
 at 09:00 friday < $filename
as /dev/null is not very verbose for debugging :)

Hope This Help
PH.
 
When you execute the else clause of the 'if [ $date = &quot;Fri&quot; ]', the variable 'filename' is undefined.
I think that your 'at' command doesn't work for that reason.


Jean Pierre.
 
Good catch Jean-Pierre, the at command is waiting reading standard input.
hubud, when your script hangs, type your EOF char (usually ^D).
And feel free to indent your script for better readability :)
 
i think aigles has it, hadn't noticed i'd declared the $filename within the first block rather than before any tesing.
The reason why i'm using at 09:00 friday < $filename > /dev/null 2>&1, is because I've had complaints from the sa due to the fact that &quot;at&quot; automatically mails the user who calls it. for some reason the user i'm using is not happy receiving mail and I'm following the sa's advice to stop him bugging me.

cheers for all the posting's

cheers

simmo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top