Sponsored Content
Top Forums Shell Programming and Scripting Shell script runs fine in Solaris, in Linux hangs at wait command Post 302466867 by aksaravanan on Wednesday 27th of October 2010 02:34:43 PM
Old 10-27-2010
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
Code:
CFG_FILE=tab25.cfg
sort -t "!" -k 2 ${CFG_FILE} | egrep -v "^#|^$" |  while IFS="!" read  a b c
do
#echo "jobs output"
#jobs
#echo "jobs -p  "
#jobs -p
# echo "Before entering parallel process  $$ "
#                jobs  -l
#if [[ `jobs | wc -l` -ne 0 ]] ; then
#               jobs|wc -l
#                ps -ef|grep "`jobs -p`"
#fi
 
wait
done

my CFG_FILE is
Code:
this_is_a_test_ttt! lask;djfl;a ljkasfl; as l;jsladfjasldfj aslk;fjas flj;asf fABCDEFGHIJ KLMNOP ABCDELKJ :LKJSDFLKJSDFKLJDFKDJF  DFKSDHFIUI JSF SIDFJISDFISJDIF  ! lkjasdflkjasf

repeated for 32 times.


if i uncomment the body of while loop , here is the output (that shows what for "wait" is waiting)
Code:
[2] +  Running                 <command unknown>
[1] -  Running                 <command unknown>
jobs -p  
28418

Before entering parallel process 28416
Code:
[2] + 28418      Running                 <command unknown>
       1 
myid   28418 28416  0 14:26 pts/31   00:00:00 egrep -v ^#|^$
myid   28421 28416  0 14:26 pts/31   00:00:00 ps -ef
myid   28422 28416  0 14:26 pts/31   00:00:00 grep 28421?28418

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 04:22 PM.. Reason: Please use code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Script runs fine on UNIX Server...Not through MSK Tool kit on Windows Server

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)
Discussion started by: madhunk
5 Replies

2. Shell Programming and Scripting

Script runs fine, but not in a cron

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)
Discussion started by: sammyk
4 Replies

3. Shell Programming and Scripting

Script Runs fine but not giving any output

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)
Discussion started by: jagadish_gaddam
7 Replies

4. Shell Programming and Scripting

awk command in script gives error while same awk command at prompt runs fine: Why?

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)
Discussion started by: catalys
4 Replies

5. Shell Programming and Scripting

CRON shell script only runs correctly on command line

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)
Discussion started by: louieaw
4 Replies

6. Shell Programming and Scripting

Script runs fine manually but not in crontab

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)
Discussion started by: umarsatti
16 Replies

7. Shell Programming and Scripting

Part of the Shell script is not running via crontab, runs fine manually

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)
Discussion started by: gowthamakanthan
18 Replies

8. Shell Programming and Scripting

Script runs in command-line fine but times out in CRON?

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)
Discussion started by: phpchick
4 Replies

9. Shell Programming and Scripting

In Shell Script Does Second Command Wait For First Command To Complete

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)
Discussion started by: angshuman
3 Replies

10. Shell Programming and Scripting

Sql command inside shell script runs without giving anything back as outout

#!/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)
Discussion started by: LoneRanger
4 Replies
atq(1)								   User Commands							    atq(1)

NAME
atq - display the jobs queued to run at specified times SYNOPSIS
atq [-c] [-n] [username]... DESCRIPTION
The atq utility displays the at jobs queued up for the current user. at(1) is a utility that allows users to execute commands at a later date. If invoked by a user with the solaris.jobs.admin authorization, atq will display all jobs in the queue. If no options are given, the jobs are displayed in chronological order of execution. When an authorized user invokes atq without specifying username, the entire queue is displayed; when a username is specified, only those jobs belonging to the named user are displayed. OPTIONS
The following options are supported: -c Displays the queued jobs in the order they were created (that is, the time that the at command was given). -n Displays only the total number of jobs currently in the queue. FILES
/var/spool/cron/atjobs spool area for at jobs. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
at(1), atrm(1), auths(1), cron(1M), auth_attr(4), attributes(5) SunOS 5.11 13 Aug 1999 atq(1)
All times are GMT -4. The time now is 10:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy