LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 06-16-2002, 07:31 PM   #1
gommo
LQ Newbie
 
Registered: Jun 2002
Location: Newcastle, Australia
Distribution: Redhat
Posts: 2

Rep: Reputation: 0
Post Getting return value of main()


I'm calling a program from a bash script and was just wondering
how I could get the return value from the program and put it into a variable in my script.

Thanks
 
Old 06-16-2002, 08:04 PM   #2
nincompoop
LQ Newbie
 
Registered: May 2002
Location: Eugene
Distribution: suse, redhat
Posts: 16

Rep: Reputation: 0
I think (meaning I could be wrong) that the last program to execute's return value is in the environment variable $?

you probably can use it as is...
 
Old 06-16-2002, 08:06 PM   #3
Saphlyx
LQ Newbie
 
Registered: Jun 2002
Location: Edmonton AB Canada
Distribution: Gentoo Linux
Posts: 1

Rep: Reputation: 0
Hi.

The return value of a application run from a script is stored in the special return value '$?'

Example:

#!/bin/sh
someapp
echo "return value of someapp was: " $?


Steve
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
return value neerajchaudhari Linux - Newbie 1 08-29-2005 01:42 AM
(2) Main Menu's? Isn't it, "there can be only one?" for the term "Main"? t3gah LQ Suggestions & Feedback 1 04-09-2005 09:30 AM
Return code from main() using gcc Meatwad Programming 13 01-27-2004 06:36 PM
How to change function parameter value and return back to the main shell program Bassam Linux - General 1 01-26-2004 10:02 AM
return linuxanswer Programming 4 10-25-2003 11:31 PM


All times are GMT -5. The time now is 04:39 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration