05-20-2008
Hi,
Just a quick reply/hint as im not a shell expert
, add "set -x" in the begining of the script, this will display all commands that are about to be executed, hopefully helping you to know where your shell might bug ...
For 'handling exceptions' you can only catch signal like segfault, sigint (user hitting break key, etc ...) with the "trap" keyword ...
Good luck hunting bugs
9 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
The following C++ code segment is not working in debug mode build on HP-UNIX machine. It is not printing "Hello World" message on the screen. While it is working fine in release mode build.
==============================================
class KLogStreamBuf : public streambuf {
public:... (0 Replies)
Discussion started by: heena
0 Replies
2. Shell Programming and Scripting
echo "input time in hhmmss"
read $st
h=`echo $st | cut -c1-2`
min=`echo $st | cut -c3-4`
s=`echo $st | cut -c5-6`
echo "input time in hhmmss"
read $end
h1=`echo $end | cut -c1-2`
min1=`echo $end | cut -c3-4`
s1=`echo $end | cut -c5-6`
x= `expr $h /* 60 + $min`
y= `expr $h1 /* 60 +... (8 Replies)
Discussion started by: abhishek27
8 Replies
3. Shell Programming and Scripting
Hi Buddies,
The following is shell scripts which was borrowed from linux box for load average check. it runs good.
(this structure is simple, when load average is too high, it will send alert to user)
#!/usr/bin/ksh
# Set threshold for 1, 5 and 15 minture load avarage
# configured for... (4 Replies)
Discussion started by: GreatJerry
4 Replies
4. Shell Programming and Scripting
Hi,
I have this script, searches and sets variables, then searches and sets more variables from multiple files.
I'd need to debug it a bit.
#!/bin/bash
egrep $1 `find | grep MAGT` >/tmp/resRA-$$
thread=`sed -n '/{0x/ {s/^.*{0x\(*\).*/\1/p;q}' /tmp/resRA-$$`
tag=`sed -n '/Tag=/... (5 Replies)
Discussion started by: Vitoriung
5 Replies
5. Shell Programming and Scripting
Hi I am relatively new in shell scripting Below is the code which i developed but for some reason, it keeps giving me error:
/apps/bss/BatchProg/at1/batch/scripts/ksh/TBATLC02.ksh: syntax error at line 41 : `then' unmatched
#!/usr/bin/ksh... (4 Replies)
Discussion started by: scripting_newbe
4 Replies
6. Shell Programming and Scripting
I know about bash -x, set -x and -v but disappears from Command Line Interface in fraction of second ......
I am looking for a command or script ..complies each line and shows the output after executing each line ....( similar what we have in C )
Thanks in Advance (2 Replies)
Discussion started by: frintocf
2 Replies
7. Shell Programming and Scripting
I have a shell program which calls a perl program.
I am running the shell program with command;
$ ksh -x <prog_name>
Inside the shell program, I am calling perl with warnings.
I want to capture the entire output as it comes on screen.
The command I tried is:
$ ksh -x... (1 Reply)
Discussion started by: som.nitk
1 Replies
8. Ubuntu
How can I debug this script?
I want to know what it is doing or not doing?
#!/bin/bash
#
#
if ; then
# Do the thing you want before suspend here
echo "we are suspending." > /tmp/systemd_suspend_test.txt
elif ; then
# Do the thing you want after resume here
echo "and we are... (21 Replies)
Discussion started by: drew77
21 Replies
9. UNIX for Beginners Questions & Answers
Hello All,
I have got a section of shell script which was working earlier but now it is giving some different results:
MSG=
while true
do
themenu
getchar =
case $answer in
1) export_Config_tables;;
2) export_config_tables_file;;
3)... (1 Reply)
Discussion started by: bghosh
1 Replies
trap(1) User Commands trap(1)
NAME
trap, onintr - shell built-in functions to respond to (hardware) signals
SYNOPSIS
sh
trap [ argument n [n2...]]
csh
onintr [-| label]
ksh
*trap [ arg sig [ sig2...]]
DESCRIPTION
sh
The trap command argument is to be read and executed when the shell receives numeric or symbolic signal(s) (n). (Note: argument is scanned
once when the trap is set and once when the trap is taken.) Trap commands are executed in order of signal number or corresponding symbolic
names. Any attempt to set a trap on a signal that was ignored on entry to the current shell is ineffective. An attempt to trap on signal 11
(memory fault) produces an error. If argument is absent all trap(s) n are reset to their original values. If argument is the null string
this signal is ignored by the shell and by the commands it invokes. If n is 0 the command argument is executed on exit from the shell. The
trap command with no arguments prints a list of commands associated with each signal number.
csh
onintr controls the action of the shell on interrupts. With no arguments, onintr restores the default action of the shell on interrupts.
(The shell terminates shell scripts and returns to the terminal command input level). With the - argument, the shell ignores all inter-
rupts. With a label argument, the shell executes a goto label when an interrupt is received or a child process terminates because it was
interrupted.
ksh
trap uses arg as a command to be read and executed when the shell receives signal(s) sig. (Note that arg is scanned once when the trap is
set and once when the trap is taken.) Each sig can be given as a number or as the name of the signal. trap commands are executed in order
of signal number. Any attempt to set a trap on a signal that was ignored on entry to the current shell is ineffective. If arg is omitted
or is -, then the trap(s) for each sig are reset to their original values. If arg is the null (the empty string, e.g., "" ) string then
this signal is ignored by the shell and by the commands it invokes. If sig is ERR then arg will be executed whenever a command has a non-
zero exit status. If sig is DEBUG then arg will be executed after each command. If sig is 0 or EXIT for a trap set outside any function
then the command arg is executed on exit from the shell. The trap command with no arguments prints a list of commands associated with each
signal number.
On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways:
1. Variable assignment lists preceding the command remain in effect when the command completes.
2. I/O redirections are processed after variable assignments.
3. Errors cause a script that contains them to abort.
4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a vari-
able assignment. This means that tilde substitution is performed after the = sign and word splitting and file name generation are not
performed.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
SEE ALSO
csh(1), exit(1), ksh(1), sh(1), attributes(5)
SunOS 5.10 23 Oct 1994 trap(1)