Solved

checking $? value

Posted on 2007-03-21
2
164 Views
Last Modified: 2010-04-16
I have written a build script which creates a bin directory and compiles java code.
I call this build.sh in another script,dailybuild.sh ,I would like to test that the script ran correctly.
For this I used $?, but this value is turning out to be 1 instead of 0 even though the build.sh is correctly running.?Basically what I want to test is that the contents of build.sh ran properly-ie the code was compiled properly.
Is there a way to test that it ran correctly?
Thanks
0
Comment
Question by:ams7503
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
FrivolousSam earned 50 total points
ID: 18766349
$? returns the exit code of the command that was last run.

You need to check where build.sh is exiting that means the last command returned a nonzero exit code.

Start at the last instruction and do something like:
echo "command: xxxx | exit code: $?"
after it.

Keep adding echo commands until you realise which command is causing the problem.
0
 

Author Comment

by:ams7503
ID: 18766512
Thank you for your help- by echoing stuff out I was able to figure out what was going wrong.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Powershell Split 18 40
powershell automatic variable for results 21 39
comm diff cmp unix commands 2 15
killall tor  && service tor start  in Python 3 36
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question