The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 get the exit status yhacks Shell Programming and Scripting 1 05-19-2008 09:06 AM
Capturing last command execution status in a script. videsh77 Shell Programming and Scripting 2 04-12-2007 02:19 PM
exit status moxxx68 Shell Programming and Scripting 1 12-04-2004 07:27 PM
tar exit status thorndike UNIX for Dummies Questions & Answers 3 01-22-2002 04:39 PM
ftp exit status. oracle8 UNIX for Advanced & Expert Users 1 10-22-2001 12:34 AM

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 Rate Thread Display Modes
  #1 (permalink)  
Old 06-04-2003
Bob Bannon Bob Bannon is offline
Registered User
  
 

Join Date: Jun 2003
Posts: 1
capturing exit status ($?) in subshell ??

I am trying to capture the exit status of a parent shell
in a subshell.
I am using the trap .. Exit command in the subshell
I cant use the export command in the parent shell to
to export a variable with the exit status to the subshell.
I would have tooooo many parent shells to change.


Parent Shell
. /subshell #Include sub shell
Code code ....
exit 1

End of Parent Shell

subshell

'trap echo $? ' EXIT

#End subshell

My problem is the echo command displays 0.

Any ideas would be greatllllly appreciated
  #2 (permalink)  
Old 06-04-2003
google's Avatar
google google is offline Forum Advisor  
Moderator
  
 

Join Date: Jul 2002
Location: Atlanta
Posts: 740
Re: capturing exit status ($?) in subshell ??

Quote:
Originally posted by Bob Bannon
I am trying to capture the exit status of a parent shell
in a subshell.
I am using the trap .. Exit command in the subshell
I cant use the export command in the parent shell to
to export a variable with the exit status to the subshell.
I would have tooooo many parent shells to change.


Parent Shell
. /subshell #Include sub shell
Code code ....
exit 1

End of Parent Shell

subshell

'trap echo $? ' EXIT

#End subshell

My problem is the echo command displays 0.

Any ideas would be greatllllly appreciated
The way you have this written, your subshell is going to execute until it completes before passing control back to your parent. Given that, your parent shouldnt fail before your child. It would be the other way around.

Last edited by google; 06-04-2003 at 06:25 PM..
  #3 (permalink)  
Old 06-04-2003
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,123
What you are calling a subshell isn't one and you seem to have parent and child mixed up.

If you write a command and call it "subshell". you can run it and get the exit code like this..

./subshell
exitcode=$?

And it doesn't matter that "subshell" is command that is also a shell script.
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 07:08 PM.


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