Test if execution was successful

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Test if execution was successful
# 1  
Test if execution was successful

How can I test inside a shel script whether the last action was successful or not.

I have the following line which is executing inside a script

. ./runProcess.sh $i $var_num>> error.txt 2>&1

This is occuring in a loop. How can i test whether it was succes for last var_num or not. How can I check that?
# 2  
If runProcess is competently written, it will set its exit code to non-zero if it fails.

if ./runProcess.sh whatever; then
  : success, do nothing
  echo "eek, failed with exit code $?" >&2
  wave hands --left --right

Last edited by era; 10-08-2008 at 10:15 AM.. Reason: Add sample code
# 3  
Be careful with the application that masks the return code with the success status of the shell from which its executing.

For example : If ftp's connection to a ftp server is not successful it will still return 0 to $? due to the reason ftp command completed successfully

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #316
Difficulty: Easy
RAM stands for Registered Access Memory.
True or False?

6 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Confirm the execution of copy command is successful or not

All, I have to copy huge file from one location to another using python . I want to make sure the execution of Copy command is successful and all the files are copied properly (there has not been any abrupt interruption to the copy process or error like no space available is encountered during... (5 Replies)
Discussion started by: IshuGupta
5 Replies

2. High Performance Computing

IBM Hardware: Test speed of an execution core reliably.

Hey Folks, Doing simple floating point or integer arithmetic is limited since if another execution core is not busy, the system will (presumably?) assign CPU resources to where they are needed so I could be getting the performance of 2 or more cores theoretically? Any good reliable way to... (2 Replies)
Discussion started by: Devyn
2 Replies

3. Shell Programming and Scripting

Prefixing test case methods with letter 'test'

Hi, I have a Python unit test cases source code file which contains more than a hundred test case methods. In that, some of the test case methods already have prefix 'test' where as some of them do not have. Now, I need to add the string 'test' (case-sensitive) as a prefix to those of the... (5 Replies)
Discussion started by: royalibrahim
5 Replies

4. Shell Programming and Scripting

How to check weather a string is like test* or test* ot *test* in if condition

How to check weather a string is like test* or test* ot *test* in if condition (5 Replies)
Discussion started by: johnjerome
5 Replies

5. Shell Programming and Scripting

Test on string containing spacewhile test 1 -eq 1 do read a $a if test $a = quitC then break fi d

This is the code: while test 1 -eq 1 do read a $a if test $a = stop then break fi done I read a command on every loop an execute it. I check if the string equals the word stop to end the loop,but it say that I gave too many arguments to test. For example echo hello. Now the... (1 Reply)
Discussion started by: Max89
1 Replies

6. Shell Programming and Scripting

Expect Issue Serial Forground Execution vs Concurrent Background Execution

I have an expect script that interrogates several hundred unix servers for both access and directories therein using "ssh user@host ls -l /path". The combination of host/path are unique but the host may be interrogated multiple times if there are multiple paths to test. The expect script is run... (2 Replies)
Discussion started by: twk
2 Replies

Featured Tech Videos