Shell script runs fine in Solaris, in Linux hangs at wait command
HI,
I have a strange problem. A shell script that runs fine on solaris. when i ported to linux, it started hanging.
here is the core of the script
my CFG_FILE is
repeated for 32 times.
if i uncomment the body of while loop , here is the output (that shows what for "wait" is waiting)
Before entering parallel process 28416
what causes this script wait for a while/grep command in linux whereas in solaris it is fine.
To give further details, i suppose to call a (8) background process, for each of line read from the file. So i introduced a wait command and when all complete i read next line and so on.
Since wait was really waiting for grep and not for spawned child, my script broke.
Othercases when it can run fine in linux
1. fewer lines in config file
2. in one test, i shrink one of row length from 260 to 250, it worked.
i can't predict a consitance condition for this behaviour.
Any help is appreciated in fixing / explaining this behaviour.
thanks
AK
Last edited by Scott; 10-27-2010 at 05:22 PM..
Reason: Please use code tags
I regret that I can't decipher what you are actually trying to acheive, however my bet is that from earlier testing you may have a background task still hanging around and the wait command is watching for all background processes to finish (jobs 1 & 2 running unknown command). Try starting a new session to ensure that is not your problem.
my apologizes for not using tag . and thanks for tagging.
1.
in both machines, i use ksh my program starts #!/bin/ksh , so it should override any shell is being used.
2. to answer the scenario , Robin's guess is right.
here is what i am doing
now in my cash, wait started waiting for a zombie (unknown command, evetually a grep , sort) and never come out to read next line.
when i was trying to simplify the problem, i removed inner for loop , so my question looks awkward(stupid?)
technically, when i have while loop and have a wait command it shouldn't wait. ofcourse linux does something in background for while loops
i even used a intermediate file for doing sort and grep output and pass it on to while loop, but wait continue to hang.
again, when i started my config file with few lines, it was working fine in linux too. when i started adding more and more lines, it gave error
at one point, when i reduced row length from 260 char to 250 char , it worked too. but script still can work with line length exceeding more than 250 char when fewer lines were there. so i can't say this is the only scenario problem is exhibited.
i don't know if i am using pdksh and realksh (i never heard pdksh earlier)
anyway, here is my output
/bin/ksh --version
version sh (AT&T Labs Research) 1993-12-28 n+
#!/bin/sh
# This script returns the number of rows updated from a function
echo "The execution is starting ....."
sqlplus -silent $UP <<EOF
set serveroutput on
set echo off
set pagesize 0
VAR no_rows_updated NUMBER;
EXEC :no_rows_updated :=0;
DECLARE
CURSOR c_update is
SELECT * FROM... (4 Replies)
Hi All,
I have a question related to Shell scripting. In my shell script, I have following two commands in sequence:
sed 's/^/grep "^120" /g' $ORIGCHARGEDAMTLIST|sed "s;$;| cut -f$FIELD_NO1 -d '|' | awk '{ sum+=\$1} END {printf (\"%0.2f\\\n\", sum/100)}' >$TEMPFILE
mv $TEMPFILE $ORIGFILE... (3 Replies)
Hi, I have a script that seems to run to completion when in the command-line, but when it is run using the cron, it seems to time out.
They both start and run fine, but on the CRON it stops prematurely.
The script hits an API every few seconds and grabs data.
Does anyone have any idea on... (4 Replies)
Hello Team,
As a part of my job we have made a script to automate a service to restart frequently.
Script having two functions when executing it's should find the existing service and kill it, then start the same service . Verified the script it's working fine when executing... (18 Replies)
Hello Guys,
I have scratched my head alot on this but couldn't find clue what's wrong. Can you please help me with this? My problem is as following.
1) When I manually execute following script it runs successfully with below output.
bash-3.00# more smssend
#!/bin/bash
echo -e "<Request... (16 Replies)
Hi, I'm new to these forums, and I'm hoping that someone can solve this problem...
To make things short:
I have DD-wrt set up on a router.
I'm trying to run a script in CRON that fetches the daily password from my database using SSH.
CRON is set like so(in web interface):
* * * *... (4 Replies)
Hello all,
Here is what my bash script does: sums number columns, saves the tot in new column, outputs if tot >= threshold val:
> cat getnon0file.sh
#!/bin/bash
this="getnon0file.sh"
USAGE=$this"
InFile="xyz.38"
Min="0.05"
#
awk '{sum=0; for(n=2; n<=NF; n++){sum+=$n};... (4 Replies)
Hi,
My script is running with no erros but not giving any output can anyonehelp.
#!/bin/ksh
. /home/application/bin/application.env
OUTFILE=Result.txt
PROD_PASSWORD=`${GET_PWD} -f ${PWD_FILE_PATH} -s ${PROD_SERVER} -u ${PROD_USER}`
echo "1)To get the book last loaded details "
read... (7 Replies)
Okay, I have the following script that runs fine from a command line as well as an executable .sh file. It just moves any file/folder with movie* in the name to a folder called _Movies. The issue I'm running into is when it's call from a cron.
find /mnt/HD_a2/BT/complete -iname "movie.*" -exec... (4 Replies)
I have a .sh script which was running fine on all the UNIX Servers (AIX, SunSolaris). The script requires two mandatory parameters and many optional parameters. Now at a different client place who are on a Windows Server, when I try to execute the script through MKS Toolkit, there are couple of... (5 Replies)