?
Solved

checking $? value

Posted on 2007-03-21
2
Medium Priority
?
166 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 200 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

Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
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…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Suggested Courses
Course of the Month10 days, 19 hours left to enroll

770 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