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
Solved

checking $? value

Posted on 2007-03-21
2
162 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
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

790 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