12-24-2006
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 file to find out success or failure of the load script, but sometimes there will be some errors even though it does not create an error log file, so its not 100% accurate.
Thanks
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
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 Advanced & Expert Users
Hi,
I am using few ISQL statements to update and delete from a few tables in sybase, now i want to roll back the transaction when any of the statements fail.How i can i capture these errors in the shell scripts.Please advise.
Thanks,
Gopi (4 Replies)
Discussion started by: bhgopi
4 Replies
3. Shell Programming and Scripting
Hi
Please let me know is there any way through which I can find out errors & do debugging in FTP scripts.
Thanks
Sourabh
TCS (1 Reply)
Discussion started by: sourabhshakya
1 Replies
4. Shell Programming and Scripting
Hi All,
Is interrupt handling possible in k shell?
Say if the user press CTRL-C or CTRl-D,I want to perform a particular action before terminating?
Thnaks! (2 Replies)
Discussion started by: prasperl
2 Replies
5. Shell Programming and Scripting
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
6. Shell Programming and Scripting
Hi,
Please help me with the below situation where I have to handle the parameters passed to a function in a unique way.
Below is the code, which I am trying to execute. I basically want to pass the parameter to a function, where I am trying to get user input into array(s). I want to name... (7 Replies)
Discussion started by: bharath.gct
7 Replies
7. Shell Programming and Scripting
Hi all...
Please help me with this questions.
I am not good at shell scripting.
1) It seems like there are many ways that we can run the shell scripts.
what is the difference between each one?
i)./shell_script.sh
ii).(space)./ shell_script.sh
iii)sh shell_script.sh
... (3 Replies)
Discussion started by: sanskumar2003
3 Replies
8. Shell Programming and Scripting
AIX 7.1
Here's the script
#!/bin/ksh
find . -print > filelist.txt
backup -ivqf/dev/rmt0 < filelist.txt > backup.log
if ; then
echo "Backup to tape failed!" >> backup.log
else
echo "Backup to tape successfull!" >> backup.log
fi
mail -v -s "Backup report" maillist < backup.log
... (4 Replies)
Discussion started by: landog
4 Replies
9. Shell Programming and Scripting
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
10. Shell Programming and Scripting
Hello
I have a file which has around 120 lines of commands.
I am trying to write a shell script like which reads the 'command' file and executes line by line with some additional (common argument) with maximum 6 commands active at a time. Each of these commands when executed takes time... (5 Replies)
Discussion started by: JackyShane_36
5 Replies
LEARN ABOUT MOJAVE
module::load
Module::Load(3pm) Perl Programmers Reference Guide Module::Load(3pm)
NAME
Module::Load - runtime require of both modules and files
SYNOPSIS
use Module::Load;
my $module = 'Data:Dumper';
load Data::Dumper; # loads that module
load 'Data::Dumper'; # ditto
load $module # tritto
my $script = 'some/script.pl'
load $script;
load 'some/script.pl'; # use quotes because of punctuations
load thing; # try 'thing' first, then 'thing.pm'
load CGI, ':standard' # like 'use CGI qw[:standard]'
DESCRIPTION
"load" eliminates the need to know whether you are trying to require either a file or a module.
If you consult "perldoc -f require" you will see that "require" will behave differently when given a bareword or a string.
In the case of a string, "require" assumes you are wanting to load a file. But in the case of a bareword, it assumes you mean a module.
This gives nasty overhead when you are trying to dynamically require modules at runtime, since you will need to change the module notation
("Acme::Comment") to a file notation fitting the particular platform you are on.
"load" eliminates the need for this overhead and will just DWYM.
Rules
"load" has the following rules to decide what it thinks you want:
o If the argument has any characters in it other than those matching "w", ":" or "'", it must be a file
o If the argument matches only "[w:']", it must be a module
o If the argument matches only "w", it could either be a module or a file. We will try to find "file.pm" first in @INC and if that
fails, we will try to find "file" in @INC. If both fail, we die with the respective error messages.
Caveats
Because of a bug in perl (#19213), at least in version 5.6.1, we have to hardcode the path separator for a require on Win32 to be "/", like
on Unix rather than the Win32 "". Otherwise perl will not read its own %INC accurately double load files if they are required again, or in
the worst case, core dump.
"Module::Load" cannot do implicit imports, only explicit imports. (in other words, you always have to specify explicitly what you wish to
import from a module, even if the functions are in that modules' @EXPORT)
ACKNOWLEDGEMENTS
Thanks to Jonas B. Nielsen for making explicit imports work.
BUG REPORTS
Please report bugs or other issues to <bug-module-load@rt.cpan.org<gt>.
AUTHOR
This module by Jos Boumans <kane@cpan.org>.
COPYRIGHT
This library is free software; you may redistribute and/or modify it under the same terms as Perl itself.
perl v5.18.2 2013-11-04 Module::Load(3pm)