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
SAFE_ASTERISK(8)					     Linux Programmer's Manual						  SAFE_ASTERISK(8)

NAME
safe_asterisk -- A wrapper to run the asterisk executable in a loop SYNOPSIS
safe_asterisk [ asterisk_params ] DESCRIPTION
safe_asterisk is a script that runs asterisk in a loop, which can be useful if you fear asterisk may crash. The script does not run in the background like a standard service. Rather, it runs in its own linux virtual console (9, by default). It also uses the option '-c' of asterisk(8) to avoid detaching asterisk from that terminal. safe_asterisk also runs asterisk with unlimited core file size, and thus asterisk will dump core in case of a crash. To get a "picture" of console 9, from another terminal (e.g: from a remote shell session) you can use: screendump 9 The init script of the Debian package should be able to run safe_asterisk as the asterisk service, if so configured. See coments in /etc/default/asterisk FILES
/tmp safe_asterisk runs in that directory, rather than in / as usual. /tmp/core If core files were generated there, they may be /etc/asterisk/startup.d Files in this directory will be 'source'd by the safe_asterisk script before it starts Asterisk proper, allowing them to set addi- tional environment variables or run any other steps that are needed for your system. BUGS
While showing the output on a console is useful, using screen(1) as the terminal may be better. The script does not read configuration from standard location under /etc It uses fixed locations under /tmp , and thus may be exposed to a symlink attacks. SEE ALSO
asterisk(8), screendump(9) AUTHOR
This manual page was written by Tzafrir Cohen <tzafrir.cohen@xorcom.com> Permission is granted to copy, distribute and/or modify this docu- ment under the terms of the GNU General Public License, Version 2 any later version published by the Free Software Foundation. On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL-2. Asterisk Jun 30th, 2005 SAFE_ASTERISK(8)
All times are GMT -4. The time now is 03:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy