The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to capture status code and echo a message laknar Shell Programming and Scripting 12 04-30-2008 11:13 AM
capture ftp return code..PLZ HELP anju Shell Programming and Scripting 3 04-03-2008 11:08 AM
Capture Oracle return code in shell script Vikas Sood Shell Programming and Scripting 1 05-22-2006 06:32 PM
Where can I find a list of exit codes? (Exit code 64) jkuchar747 UNIX for Dummies Questions & Answers 3 12-07-2004 06:08 PM
All about exit code cdin2 Shell Programming and Scripting 2 03-11-2002 10:03 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 4.00 average. Display Modes
  #1 (permalink)  
Old 11-12-2008
ChicagoBlues ChicagoBlues is offline
Registered User
  
 

Join Date: Jan 2008
Location: Chicago
Posts: 77
How to capture exit code for a bg job

If I execute a job in background (in ksh or bash), how would I capture the exit code for that job?

Thanks,

- CB
  #2 (permalink)  
Old 11-15-2008
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,131

Code:
#! /usr/bin/ksh


false &
pid=$!
wait $pid
result=$?
echo result of false is $result

true &
pid=$!
wait $pid
result=$?
echo result of true is $result
exit 0
$
$
$ ./back
result of false is 1
result of true is 0
$

Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:21 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0