The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
the given code goes in infinite loop and does not increment variable i mrityunjay22 Shell Programming and Scripting 6 12-25-2007 10:20 PM
pick the bug the server enters an infinite loop arjunjag High Level Programming 3 07-18-2007 10:53 PM
ls command in infinite Loop umakant SUN Solaris 3 07-16-2007 10:25 PM
Script not running in AutoSys ramsi_ece Shell Programming and Scripting 2 07-11-2007 08:43 AM
high priority thread contains an infinite loop rvan High Level Programming 0 02-14-2007 05:30 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-04-2007
Registered User
 

Join Date: Sep 2007
Posts: 2
Stumble this Post!
Thumbs down Infinite Loop in Autosys while running a shell script, Manual run is fine

Hi All,

I have a shell script, which runs fine manually, but goes into infinite loop, when run through Autosys Scheduler.
The part of code going in infinite loop is pasted below:


*************this is only a part of code*****************

i=0
while [ $i -lt $split ]
do
#echo start $start and end $end
sed -n ''$start','$end'p' $dir/$filename >> $dir/$fldr/input.csv
cat $dir/$fldr/header.csv $dir/$fldr/input.csv >> $dir/$fldr/input_`expr $i + 1`.csv
echo `date +%m%d%y_%T`--$dir/$fldr/input_`expr $i + 1`.csv created >> $log
rm -f $dir/$fldr/input.csv
start=`expr $end + 1`
if [ $i -eq `expr $split - 2` ]; then
start=`expr $end + 1`
end=`expr $filecnt`
else
end=`expr $start + $flsize - 1`
fi
#cat input_`expr $i + 1`.csv
let "i=$i+1"
done

***************************************************


in the last but one line, i am using
let"i=$i+1"

I tried using
i=`expr $i + 1`

but still the script goes in infinite loop...



Need some suggestions...
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 09-04-2007
Registered User
 

Join Date: Aug 2007
Posts: 45
Stumble this Post!
check $split where it comes from.

let "i=$i+1" is true there is no need to check expr or etc.
and addition let "i=$i+1" is not dependent on a line of code before it. So it must be to possibilities

1. it is not a infinite loop it is waiting on a line before let
2. if it is $split is empty or something else what you expected
Reply With Quote
  #3 (permalink)  
Old 09-04-2007
Registered User
 

Join Date: Sep 2007
Posts: 2
Stumble this Post!
Thumbs up

I made few corrections in the script, and it worked fine...

1. I defined a temporary variable x to calculate the value of `$i + 1`, as it was not getting passed in echo and cat in the original script.
2. I replaced let with expr, as the autosys server of ous is not having the functionality of let.

Script pasted below:

*******************************************************

while [ $i -lt $split ]
do
#echo start $start and end $end
x=`expr $i + 1`
sed -n ''$start','$end'p' $dir/$filename >> $dir/$fldr/input.csv
cat $dir/$fldr/header.csv $dir/$fldr/input.csv >> $dir/$fldr/input_$x.csv
echo `date +%m%d%y_%T`--$dir/$fldr/input_$x.csv created >> $log
rm -f $dir/$fldr/input.csv
start=`expr $end + 1`
if [ $i -eq `expr $split - 2` ]; then
start=`expr $end + 1`
end=`expr $filecnt`
else
end=`expr $start + $flsize - 1`
fi
#cat input_`expr $i + 1`.csv
let "i=$i+1"
done

*******************************************************



I would like to clarify two thing on this regard:

1. Is it so that autosys is not able to calculate the parameter value at runtime. If so, what does Autosys scheduler do other than just scheduling the script.

2. Is it so that the autosys server, and shell script server should have same set of commands in their command list.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
autosys

Thread Tools
Display Modes




All times are GMT -7. The time now is 08:47 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0