Sponsored Content
Full Discussion: until loop fails.
Top Forums Shell Programming and Scripting until loop fails. Post 302353787 by methyl on Wednesday 16th of September 2009 08:22:18 AM
Old 09-16-2009
Ambiguous.
You wrote:
Quote:
trying to print ".." until the process exist..
i am simple trying to print ".." until the bg process runs and then continue with the rest part of the script
I assume you mean:
Quote:
trying to print ".." until the process exits..
i am simple trying to print ".." until the bg process completes and then continue with the rest part of the script
Or do you actually mean:
Quote:
trying to print ".." until the process exists..
i am simple trying to print ".." until the bg process starts running and then continue with the rest part of the script


Contrary to previous posts, try "jobs" not "ps" to check whether your background job is running.
Assuming you want to wait for the background process to complete.

Code:
/tmp/test/abc.sh &
while true
do
       if [ -z "`jobs`" ]
       then
              # Background job has finished
              break
       else
              # Background job is still running
              echo "..\c"
              sleep 5
       fi
done

 

10 More Discussions You Might Find Interesting

1. AIX

SCP fails sometimes

Hi, I got a unix script which copies a file from my AIX machine to a file server using SCP command. I am calling this script 3 times in my process after a time interval say 5mins. My issue here is like most of the time its not sending the file at the first time run while other 2 will work fine.... (10 Replies)
Discussion started by: vipinc
10 Replies

2. Programming

system() fails

Hi, I have the following code which fails with return value 1. sprintf(tmp, "rm -rf %s/* 2>/dev/null\n", dest); rc = system( tmp ); rc is 1 The files exist and the paths are correct. I can do a manual copy but the application fails. All the calls to system() function fail with the same... (6 Replies)
Discussion started by: mspaper
6 Replies

3. Shell Programming and Scripting

Using variables created sequentially in a loop while still inside of the loop [bash]

I'm trying to understand if it's possible to create a set of variables that are numbered based on another variable (using eval) in a loop, and then call on it before the loop ends. As an example I've written a script called question (The fist command is to show what is the contents of the... (2 Replies)
Discussion started by: DeCoTwc
2 Replies

4. Shell Programming and Scripting

Null Handling in Until loop. . .loop won't stop

Hi Im running this script, which is supposed to find the max value build some tables and then stop running once all the tables are built. Thing is , it keeps assigning a null value to $h and then $g is null so it keep building tables i.e. testupdateNUL. How can I stop this? Here is what I have: ... (4 Replies)
Discussion started by: brandono66
4 Replies

5. Programming

realloc fails in C : what next ?

Hi all I'm trying to use someone else's software, which has a realloc that fails in it. This is probably due to memory limitations, as it only happens when I use this software on huge datasets. First question : how to diagnose if it's a soft or hard limitation? I mean, if it's due to my... (10 Replies)
Discussion started by: jossojjos
10 Replies

6. Programming

realloc() fails

Not sure in which forum to post this. I'm trying here, in Programming. I'm working on a PC with Intel Duo processor & 2GB of ram. OS is Ubuntu 10.04. I'm having problems with a C++ program that makes extensive use of realloc(). It happens that as soon as the overall memory allocated(OS +... (14 Replies)
Discussion started by: mamboknave
14 Replies

7. Shell Programming and Scripting

Array Variable being Assigned Values in Loop, But Gone when Loop Completes???

Hello All, Maybe I'm Missing something here but I have NOOO idea what the heck is going on with this....? I have a Variable that contains a PATTERN of what I'm considering "Illegal Characters". So what I'm doing is looping through a string containing some of these "Illegal Characters". Now... (5 Replies)
Discussion started by: mrm5102
5 Replies

8. Shell Programming and Scripting

While loop not reading all files if ssh fails

The below while loop is in ksh on a SunOs server: SPARC-Enterprise 5.10 The ksh version is: Version M-11/16/88i The intention of the below while loop is to read through a list of file names in files.txt and delete each file from a server, one at a time. The delete works, the problem is that if... (6 Replies)
Discussion started by: LES2013
6 Replies

9. Shell Programming and Scripting

Reset while loop to loop same file multiple times

Hi, I want to read file multiple times. Right now i am using while loop but that is not working. ex. While read line do while read line2 do echo stmt1 #processing some data based on data., done < file2.txt done < file1.txt # This will have 10... (4 Replies)
Discussion started by: tmalik79
4 Replies

10. Shell Programming and Scripting

awk loop using array:wish to store array values from loop for use outside loop

Here's my code: awk -F '' 'NR==FNR { if (/time/ && $5>10) A=$2" "$3":"$4":"($5-01) else if (/time/ && $5<01) A=$2" "$3":"$4-01":"(59-$5) else if (/time/ && $5<=10) A=$2" "$3":"$4":0"($5-01) else if (/close/) { B=0 n1=n2; ... (2 Replies)
Discussion started by: klane
2 Replies
stopping(7)						 Miscellaneous Information Manual					       stopping(7)

NAME
stopping - event signalling that a job is stopping SYNOPSIS
stopping JOB=JOB INSTANCE=INSTANCE RESULT=RESULT [PROCESS=PROCESS] [EXIT_STATUS=STATUS] [EXIT_SIGNAL=SIGNAL] [ENV]... DESCRIPTION
The stopping event is generated by the Upstart init(8) daemon when an instance of a job begins stopping. The JOB environment variable con- tains the job name, and the INSTANCE environment variable contains the instance name which will be empty for single-instance jobs. If the job is stopping normally, the RESULT environment variable will be ok, otherwise if the job is stopping because it has failed it will be failed. When the job has failed, the process that failed will be given in the PROCESS environment variable. This may be pre-start, post-start, main, pre-stop or post-stop; it may also be the special value respawn to indicate that the job is stopping because it hit the respawn limit. Finally in the case of a failed job, one of either EXIT_STATUS or EXIT_SIGNAL may be given to indicate the cause of the stop. Either EXIT_STATUS will contain the exit status code of the process, or EXIT_SIGNAL will contain the name of the signal that the process received. The normal exit job configuration stanza can be used to prevent particular exit status values or signals resulting in a failed job, see init(5) for more information. If neither EXIT_STATUS or EXIT_SIGNAL is given for a failed process, it is because the process failed to spawn (for example, file not found). See the system logs for the error. init(8) will wait for all services started by this event to be running, all tasks started by this event to have finished and all jobs stopped by this event to be stopped before allowing the job to continue stopping. This allows jobs to depend on other jobs, safely stopping themselves before their dependency goes away. This event is typically combined with the started(7) event by services. Job configuration files may use the export stanza to export environment variables from their own environment into the stopping event. See init(5) for more details. EXAMPLE
A service that wishes to depend on another service might use: start on started apache stop on stopping apache A task that must be run before another task or service is stopped might use: start on stopping postgresql RESULT=ok SEE ALSO
starting(7) started(7) stopped(7) init(5) Upstart 2009-07-09 stopping(7)
All times are GMT -4. The time now is 11:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy