![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to include RETURN KEY with Background process "&" in Shell Script | racbern | Shell Programming and Scripting | 1 | 03-11-2008 07:30 AM |
| getting the return code of forked child process (ftp) | KittyJ | High Level Programming | 7 | 08-19-2007 04:44 AM |
| return code of a process | filedeliver | High Level Programming | 1 | 04-19-2007 02:42 AM |
| return code of a process | filedeliver | UNIX for Advanced & Expert Users | 1 | 04-18-2007 04:27 PM |
| background process return code | Vikas Sood | Shell Programming and Scripting | 5 | 06-10-2006 10:25 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Return code of background process
Hi, I have a process that I run in the background that looks like this Code:
${BASEDIR}/ksh/sqler.ksh ${compnames003[$i]} &
and I would like to get the return code of the sqler.ksh script. so my code is like this Code:
${BASEDIR}/ksh/sqler.ksh ${compnames003[$i]} &
retcode=$?
but this always returns 0 becuase the last statment it run was the & so is there a way to get the return code of the sqler script rather than the return code of the background process. If I remove the background processing it works.. so Code:
${BASEDIR}/ksh/sqler.ksh ${compnames003[$i]}
retcode=$?
works but its not running in the background Thanks |
|
||||
|
The return code can only be reaped when the process finishes. Have a look at the wait command. (You will want to wait on that specific process; you get its process ID in $! when you have just started it.)
|
|
||||
|
Hey era,
I was using wait but without the pid, I just literally had "wait" directly underneath. but now I've changed it to waid for the pid and its now returning the failure code! ![]() Out of interest is the reason it only returns 0 because it doesn't know what process your referring to if you just use wait witout the pid? Thanks for the help. |
|
||||
|
Code:
bash$ help wait
wait: wait [n]
Wait for the specified process and report its termination status. If
N is not given, all currently active child processes are waited for,
and the return code is zero. N may be a process ID or a job
specification; if a job spec is given, all processes in the job's
pipeline are waited for.
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|