Sponsored Content
Top Forums UNIX for Advanced & Expert Users Error Handling in Korn Shell scripts Post 82528 by bakunin on Friday 2nd of September 2005 05:03:18 AM
Old 09-02-2005
catch the errorlevel of the command:

[code]
...
/path/to/somecommand ; RC=$?
if [ $RC -eq 0 ] ; then
print - "everything worked out fine"
else
print - "something screwed up"
fi
[code]

The errorlevel is set anew for every command issued, so be sure to get it as soon as the program in question is finished.

bakunin

Last edited by RTM; 09-02-2005 at 09:50 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Null handling in scripts

Hi, I face some problem with handling of nulls. I declare a variable - say i - and intialise to 0. Later I read it from console, wherein if I dont give any variable and press return key, I get this error: "0403-004 Specify a parameter with this command" Is there anyway to handle this error? ... (3 Replies)
Discussion started by: mohanprabu
3 Replies

2. UNIX for Dummies Questions & Answers

Handling Errors in Shell Scripts

I have a shell script, which calls a load script to load a database. How can i handle errors in Unix(similar to 'error level' in Batch scripts)? I am trying to use 'mailx' to send a Success/failure message based on the error level returned by the load script. I have already used an error log... (2 Replies)
Discussion started by: sarsani
2 Replies

3. Shell Programming and Scripting

Korn Shell Script to find out error in logfile

Hi All, I am new to this forum as well as to unix scripting. Can you please help me to create a korn shell script to find out errors in logfiles and get the name of that logfile ( which is having error) in email and email it to me? (2 Replies)
Discussion started by: jithu
2 Replies

4. Shell Programming and Scripting

Error with korn shell - arrays

Hi All I have a FTP script which FTPs few files into an user folder. I intend to keep track of the folder size before FTP and after FTP and print that once the FTP script is run (a kind of comparison, "Before FTP, "After FTP"). I decided to use kron shells to accomplish this. #! /bin/ksh ... (2 Replies)
Discussion started by: guruparan18
2 Replies

5. Shell Programming and Scripting

Error handling in Unix shell scripting

Hello, I have written a shell script and suppose there is any error in the script. How i can do exception handling in shell script.for example i have below code sqlplus -s <<uid>>/<<pwd>>@<<$ORACLE_SID>> <<EOF > 1_pid1.log set pagesize 0 set feedback off set heading off set linesize 200... (1 Reply)
Discussion started by: rksingh003
1 Replies

6. Shell Programming and Scripting

Advanced error handling in shell scripts

Hi all I've got a question regarding error handling in shell scripts. My background is mainly object oriented programming languages, but for a year or so I've been doing more and more (bash) shell scripting (which I quite enjoy by the way). To handle errors in my scripts I... (3 Replies)
Discussion started by: script_man
3 Replies

7. Shell Programming and Scripting

korn shell script executed with error

Hi, need help, I would like to know what is this IF statement trying to do? When the script is executing and error out with line 9 which is the IF statement line. if ] then TOPDIR=$(pwd) else TOPDIR=${0%/*} fi TOPDIR=${TOPDIR%/*} the log file. Current system time is... (15 Replies)
Discussion started by: beooi
15 Replies

8. Shell Programming and Scripting

Not able to capture sftp error in Korn Shell

I am not able to capture error condition in sftp in Korn Shell #!/bin/ksh sftp batch@uat >abc 2>&1 << ENDFILE cd public put /data/WELCOME_55 ENDFILE ret_val=$? if ] then print file "copied successfully" else print file "NOT copied successfully" fi return 0 Now the... (9 Replies)
Discussion started by: Soham
9 Replies

9. Shell Programming and Scripting

[Solved] How to refer more than 9 command line inputs for a scripts in korn shell?

Hi all, I have a script which should take more than 9 command line inputs while running. Likescript.sh a s d f g h j j k l o p i u y t r e w Now in the script if I have to access one of the input which is at position after 9, in this case say 'p' then how can I do that? echo $12 will not work... (15 Replies)
Discussion started by: pat_pramod
15 Replies

10. Shell Programming and Scripting

Handling scripts in two different servers

Hi , My Script work as below 1- On server 1 execute script1.sh , through this script one parameter file is generated as file.txt this is to transfer on server 2 2- After reaching on server2 other shell script script2.sh execute using parameter file file.txt This generate file... (1 Reply)
Discussion started by: kaushik02018
1 Replies
action(3pm)						User Contributed Perl Documentation					       action(3pm)

NAME
OpaL::action - Perl extension for easier handling of what information that should be presented when a action is made. SYNOPSIS
use OpaL::action qw(functionnames); No functions or variables are exported automaticly so you have to specify them here. DESCRIPTION
OpaL::action is a module to allow some better bugtracking and information to be sent to the user/developer. All functions are autoloaded so they will not be loaded into memory if you have not used them before. There are 5 different levels of the information/action. 1. critical 2. error 3. warning 4. message 5. debug FUNCTIONS
setQuitLevel You can set on what errorlevel the program should exit if an error occur. The default level is 2 and you canges it like this: USAGE: "setQuitLevel"(level); setErrorHandler You can set an alternative error handler function (no arguments). The default one is exit. USAGE: "setErrorHandler"(funcname); setDebugLevel You can set on what errorlevel the program should output messages if an error occur. The debug level indicates what type of information that should be presented to the user. USAGE: "setDebugLevel"(level); getQuitLevel You can set on what errorlevel the program should exit if an error occur. USAGE: $foo = "getQuitLevel"; getDebugLevel You can get the debuglevel on which the program should output messages, if an error occurs. USAGE: $foo = "getDebugLevel"; pdebug You can set on what errorlevel the program should exit if an error occur. With the pdebug method you can present information and mark it with a debuglevel using: USAGE: "pdebug"(level, "A sample informational text." [,funcref]); action With this function you can handle and print a message if a function does not work correctly. It will exit the program and print a message with the error level before if the action returns true and if the action_critic is lower or equal to the set error level. If the debug level is high enough it will present the message but without the trailing error message. USAGE: "action"(some_action, "A sample informational text about the action.", how_critical [,funcref]); The last parameter (how_critical) is optional. cmdaction Actually the same as action with the difference that it executes a external command instead. It is almost identical to action(system"a command to execute", ...); USAGE: "cmdaction"("a command to execute.", "A sample informational text about the action.", how_critical, how_quiet [,funcref]); The two last parameter (how_critical) is optional. The last parameter tells how quiet the executing command should be: 0 - extremely quiet (ie: >& /dev/null) 1 - quiet (ie: >& /dev/null) 2 - everything sent to stdout. =back AUTHOR
Ola Lundqvist <ola@inguza.com> SEE ALSO
perl(1). POD ERRORS
Hey! The above document had some coding errors, which are explained below: Around line 415: You forgot a '=back' before '=head1' perl v5.10.1 2009-04-21 action(3pm)
All times are GMT -4. The time now is 05:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy