script has been executed successfully or not??


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script has been executed successfully or not??
# 1  
Old 07-21-2011
script has been executed successfully or not??

Guys,

How can we know whether a script has been executed successfully or not ?
We dont have any log directories, and we are not given a chance to modify the script. Could someone help me out with this Thanks
# 2  
Old 07-21-2011
Code:
echo $?

If this script is a "right" script it should return 0 with success and non-zero value with failure. (You can see return value - exit status - in $? variable, but you should check it immediately after executing script).
This User Gave Thanks to yazu For This Post:
# 3  
Old 07-21-2011
A shell script could have many unix commands.

Each command has its own return code stored in the variable "$?".

Whoever is writing the script should make use of the "$?" return code variable after
a questionable unix command execution and display the appropriate error message.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To check if the JAVA Program is successfully executed in sh shell scripting

Hi , I have written a shell script to call a java program say load_id.sh .This sh script indeed is executed implicitly in other sh script which calls 2 more sh scripts one by one. I need to check if the load_id.sh (which calls java program) is executed successfully only then continue with... (1 Reply)
Discussion started by: preema
1 Replies

2. Shell Programming and Scripting

Shell script replied multiple process for file has successfully created

Hi All, I have written the following code do FILE_NO=$(echo $LINE|awk -F"|" '{print $1}'|tr "'" '+'|sed 's/\(.*\)\(++\)\(.*\)\(++\)/\3/') INST_NO=$(echo $LINE|awk -F"|" '{print $2}'|tr "'" '+'|sed 's/\(.*\)\(++\)\(.*\)\(++\)/\3/') if ] then ... (3 Replies)
Discussion started by: yogendra.barode
3 Replies

3. Shell Programming and Scripting

Need to echo command successful if command is executed successfully

Hello, I have written a command n shell script : srvctl relocate service -d t1 -s s1 -i i1 -t t1 -f If the above command executes successfully without error I need to echo "Service relocated successfully and If it errors out I need to trap the errors in a file and also need to make... (1 Reply)
Discussion started by: Vishal_dba
1 Replies

4. UNIX for Dummies Questions & Answers

Print script is completed successfully or not

Hai guys I am running three shellscripts through Gtk2-Perl(GUI) these are the scripts Drccalibrescript1 script2 script3 Gtk2-Perl(GUI) drccalibre -> If I run this script through Gtk2-Perl(GUI) these are results of the drccalibrescript1 . summary/.results I have to find size of... (1 Reply)
Discussion started by: kiran425
1 Replies

5. Shell Programming and Scripting

Did my script execute successfully ?

Hi, I have two scripts viz and I am running them in background. I wish to know if both the scripts completed execution successfully. So this is what I have done /tmp/commet/bin/connectdb1.sh & condb1=$? /tmp/commet/bin/connectdb2.sh & condb2=$? However, I am getting error... (7 Replies)
Discussion started by: mohtashims
7 Replies

6. Shell Programming and Scripting

Script failing to run successfully on remote node

Hi guys, I have a scenario where i want to run a script from Node A. It ssh's into Node B and runs some awk commands there plus deposiriting the output on Node B. Challenge is that the awk commands run properly when executed locally on Node B but fail when within the script on Node B. I do not... (0 Replies)
Discussion started by: jerkesler
0 Replies

7. AIX

Script not getting executed via cron but executes when executed manually.

Hi Script not getting executed via cron but executes successfully when executed manually. Please assist cbspsap01(appuser) /app/scripts > cat restart.sh #!/bin/ksh cd /app/bin date >>logfile.out echo "Restart has been started....." >>logfile.out date >>logfile.out initfnsw -y restart... (3 Replies)
Discussion started by: samsungsamsung
3 Replies

8. Shell Programming and Scripting

System Command dies even when command gets executed successfully

Hi I have created a perl script & running it using Linux machine. I want my script to die when system command is unsuccessful but script is dying even when system command gets executed successfully. :wall: I am using the command below :- system($cmd) || die "FAILED $!"; print "Hello"; ... (2 Replies)
Discussion started by: Priyanka Gupta
2 Replies

9. UNIX for Advanced & Expert Users

Script working successfully only when executed twice

Guys, i am facing a very strange issue, my code below does an ftp to server A and gets a file to Server B, once the file is in B an if condition is present to check if the pattern of the filename is ABC* then it has to be encrypted using OPENSSL as ABC.enc else if it of pattern 123* has to be... (3 Replies)
Discussion started by: meva
3 Replies
Login or Register to Ask a Question