Sponsored Content
Full Discussion: help with return codes
Top Forums Shell Programming and Scripting help with return codes Post 302164306 by grumpf on Monday 4th of February 2008 11:44:52 AM
Old 02-04-2008
works for me:

$ LANG=C ./test.sh
Can't open perl script "print hello": No such file or directory
2 <<= return code != 0


you can check success:

$perl -e 'print "hello\n" ' ; echo $?
hello
0


you can change the return value:
$perl -e 'print "hello\n"; exit 99; ' ; echo $?
hello
99
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Help with Return codes

I have the below script I am running on a Solaris system to check the status of a Tivoli Workload Scheduler job and return the status. We need this script to return a '0' if any of the jobs in the stream are in a "EXEC" state and an "1" if in a "HOLD" state. I am not a programmer so I am not sure... (1 Reply)
Discussion started by: leezer1204
1 Replies

2. UNIX for Dummies Questions & Answers

unix return codes

Suppose I have a script which is monitoring a directory whenever a file drops in that directory,it sends alert say I want to write a return code for the above script which on successful execution of script gives a return value Based on return code , I want to do initiate some jobs in other... (1 Reply)
Discussion started by: abhib45
1 Replies

3. UNIX for Dummies Questions & Answers

Return codes

Hi, Can anyone tell me if there are return codes for SFTP? If so how would you capture them? I've tried 'man sftp' but its not particularly helpful. Many thanks Helen :confused: (4 Replies)
Discussion started by: Bab00shka
4 Replies

4. UNIX for Advanced & Expert Users

Return Codes

I have a simple script which renames a file.How do i capture the return code of the script if the script fails (3 Replies)
Discussion started by: kris01752
3 Replies

5. HP-UX

Return codes of RDIST

Can any body please tell me the return codes of RDIST tool? I am using RDIST (through an UNIX script) to synchronize files between two servers say ukblx151(source) & ukapx050(target). RDIST raises an alert mail (through notify option) in case of success & also failure but there is a problem if... (0 Replies)
Discussion started by: vishal_ranjan
0 Replies

6. UNIX for Dummies Questions & Answers

Displaying Return Codes

This is a high-level explanation, if more details are needed, please do not hesitate to ask. I have a set of .ctl files which I want to execute: AV1.ctl AV2.ctl AV3.ctl I have a script which has a for loop in it: for filename in AV1 AV2 AV3 do . execute_another_script.sh done ... (2 Replies)
Discussion started by: hern14
2 Replies

7. Shell Programming and Scripting

sftp return codes

sftp -v b $putlist $SFTP_ID@TARGET_SERVER How can I get a return code if fails to put the file? sftp -v b $getlist $SFTP_ID@TARGET_SERVER How can I get a return code if fails to put the file? (1 Reply)
Discussion started by: TimHortons
1 Replies

8. Shell Programming and Scripting

Different Return Codes

Hi, I wanted to know the significance of different return codes when we do echo $? I know when $? returns 0 the command has worked successfully. but what does $? = 1, 2, 3 etc. signify. Thanks in advance for the help !!! (3 Replies)
Discussion started by: aarti.popi
3 Replies

9. UNIX and Linux Applications

Oracle return codes?

Having searched high and low through Oracles documentation, I came to think that they're very scripting-averse, as there's (apparently) no list of possible return/exit codes for their various command line utilities. Is anyone here in possession of such a list, or knows where to find one? It... (16 Replies)
Discussion started by: pludi
16 Replies

10. UNIX for Dummies Questions & Answers

Return Codes...

Not sure if this is of any use but...... I was messing around with getting return codes greater than 255 for special usage... Of course the code could be made simple but in this code the new stored return code is generated as exit is progressing... #!/bin/sh # Real and imaginary return... (9 Replies)
Discussion started by: wisecracker
9 Replies
catch(n)						       Tcl Built-In Commands							  catch(n)

__________________________________________________________________________________________________________________________________________________

NAME
catch - Evaluate script and trap exceptional returns SYNOPSIS
catch script ?resultVarName? ?optionsVarName? _________________________________________________________________ DESCRIPTION
The catch command may be used to prevent errors from aborting command interpretation. The catch command calls the Tcl interpreter recur- sively to execute script, and always returns without raising an error, regardless of any errors that might occur while executing script. If script raises an error, catch will return a non-zero integer value corresponding to the exceptional return code returned by evaluation of script. Tcl defines the normal return code from script evaluation to be zero (0), or TCL_OK. Tcl also defines four exceptional return codes: 1 (TCL_ERROR), 2 (TCL_RETURN), 3 (TCL_BREAK), and 4 (TCL_CONTINUE). Errors during evaluation of a script are indicated by a return code of TCL_ERROR. The other exceptional return codes are returned by the return, break, and continue commands and in other special situa- tions as documented. Tcl packages can define new commands that return other integer values as return codes as well, and scripts that make use of the return -code command can also have return codes other than the five defined by Tcl. If the resultVarName argument is given, then the variable it names is set to the result of the script evaluation. When the return code from the script is 1 (TCL_ERROR), the value stored in resultVarName is an error message. When the return code from the script is 0 (TCL_OK), the value stored in resultVarName is the value returned from script. If the optionsVarName argument is given, then the variable it names is set to a dictionary of return options returned by evaluation of | script. Tcl specifies two entries that are always defined in the dictionary: -code and -level. When the return code from evaluation of | script is not TCL_RETURN, the value of the -level entry will be 0, and the value of the -code entry will be the same as the return code. | Only when the return code is TCL_RETURN will the values of the -level and -code entries be something else, as further described in the doc- | umentation for the return command. | When the return code from evaluation of script is TCL_ERROR, three additional entries are defined in the dictionary of return options | stored in optionsVarName: -errorinfo, -errorcode, and -errorline. The value of the -errorinfo entry is a formatted stack trace containing | more information about the context in which the error happened. The formatted stack trace is meant to be read by a person. The value of | the -errorcode entry is additional information about the error stored as a list. The -errorcode value is meant to be further processed by | programs, and may not be particularly readable by people. The value of the -errorline entry is an integer indicating which line of script | was being evaluated when the error occurred. The values of the -errorinfo and -errorcode entries of the most recent error are also avail- | able as values of the global variables ::errorInfo and ::errorCode respectively. | Tcl packages may provide commands that set other entries in the dictionary of return options, and the return command may be used by scripts | to set return options in addition to those defined above. EXAMPLES
The catch command may be used in an if to branch based on the success of a script. if { [catch {open $someFile w} fid] } { puts stderr "Could not open $someFile for writing $fid" exit 1 } There are more complex examples of catch usage in the documentation for the return command. SEE ALSO
break(n), continue(n), dict(n), error(n), return(n), tclvars(n) KEYWORDS
catch, error Tcl 8.5 catch(n)
All times are GMT -4. The time now is 01:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy