Print Error with set command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Print Error with set command
# 1  
Old 03-06-2009
Print Error with set command

I need to print some mandatory instructions if something fails in the script. I am using set -e to check and exit the script if some scripts/commands return non zero exit code. Is there any way to print these instructions with set command??
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed - print only the chars that match a given set in a string

For a given string that may contain any ASCII chars, i.e. that matches .*, find and print only the chars that are in a given subset. The string could also have numbers, uppercase, special chars such as ~!@#$%^&*(){}\", whatever a user could type in without going esoteric For simplicity take... (1 Reply)
Discussion started by: naderra
1 Replies

2. Shell Programming and Scripting

HHow to print the group with a highest value within a set

How to print the names with a highest value within a set and filter if it is the only unique group within the same set input sets names value groups j007 shot1 0.6 a j007 shot2 0.5 b j007 shot3 0.4 bb j007 shot4 0.3 bc j007 shot5 0.2 ... (8 Replies)
Discussion started by: quincyjones
8 Replies

3. Shell Programming and Scripting

Print specific lines of a repeated set of data

I have a file that needs 1st line, 2nd line, and 26th line printed from every chunk of data. Each chunk of data contains 26 lines (#line+%line+24 data lines = 26 lines of data repeated). Input file: # This is a data file used for blockA (chunk 1). % 10576 A 10 0 1 04 (data1) 03 (data2)... (2 Replies)
Discussion started by: morrbie
2 Replies

4. Shell Programming and Scripting

Error in script for set command

Hi All I have a function in a Linux script as follows echo `date`": Info: Started Checking File Pattern(s)" cat ${CM_FILE_SPLIT_LST} | while read SPLIT_INFO do #lets not expand wildcards set -f #FILE_PATTERN=`echo ${SPLIT_INFO} | awk '{FS="|"; print $1}'` ... (6 Replies)
Discussion started by: vee_789
6 Replies

5. HP-UX

What is the use of command set -- and set - variable?

Hi, I am using hp unix i want to know the use of the following commands set -- set - variable thanks (4 Replies)
Discussion started by: gomathi
4 Replies

6. Shell Programming and Scripting

print running field average for a set of lines

Hi everyone, I have a program that generates logs that contains sections like this: IMAGE INPUT 81 0 0.995 2449470 0 1726 368 1 0.0635 0.3291 82 0 1.001 2448013 0 1666 365 1 0.0649 0.3235 83 0 1.009 2444822 0 1697 371 1 ... (3 Replies)
Discussion started by: euval
3 Replies

7. Shell Programming and Scripting

set -o vi giving set: Syntax error

when trying : set -o vi getting error like- : set: Syntax error help me Double post (of sorts). Continue here. (0 Replies)
Discussion started by: RahulJoshi
0 Replies

8. Shell Programming and Scripting

How to print error and exit if command fails?

Guys any tips on printing a certain error message to stderr and exiting should a command fail within a ksh script? I'm trying to null some output files. Touch isn't suitable as i need to null them. print "" > file isn't suitable as i need to check elsehere for if they are 0bytes or not. ... (5 Replies)
Discussion started by: lavascript
5 Replies

9. AIX

Can you set up a networked printer as a local print queue?

Fairly simple question, I think. Still trying to get my head around AIX print queues. Most of our problems seem to stem from print queues going down. This generates help-desk calls when users call up to get their queues started or to get rid of the emails that qdaemon sends them. Looking at... (0 Replies)
Discussion started by: alexop
0 Replies

10. Solaris

how to set font for Print

I want one help from you.I got one printer related task in which when user is printing some doc , Font size is big. He want to reduce the size.we are using SUN SOLARIS (Text Based - NON GUI) operation system. Can you tell me , what could be the reason and how to check default font size and style... (0 Replies)
Discussion started by: ahuja_kishor
0 Replies
Login or Register to Ask a Question
exit(1)                                                            User Commands                                                           exit(1)

NAME
exit, return, goto - shell built-in functions to enable the execution of the shell to advance beyond its sequence of steps SYNOPSIS
sh exit [n] return [n] csh exit [ ( expr )] goto label ksh *exit [n] *return [n] DESCRIPTION
sh exit will cause the calling shell or shell script to exit with the exit status specified by n. If n is omitted the exit status is that of the last command executed (an EOF will also cause the shell to exit.) return causes a function to exit with the return value specified by n. If n is omitted, the return status is that of the last command exe- cuted. csh exit will cause the calling shell or shell script to exit, either with the value of the status variable or with the value specified by the expression expr. The goto built-in uses a specified label as a search string amongst commands. The shell rewinds its input as much as possible and searches for a line of the form label: possibly preceded by space or tab characters. Execution continues after the indicated line. It is an error to jump to a label that occurs between a while or for built-in command and its corresponding end. ksh exit will cause the calling shell or shell script to exit with the exit status specified by n. The value will be the least significant 8 bits of the specified status. If n is omitted then the exit status is that of the last command executed. When exit occurs when executing a trap, the last command refers to the command that executed before the trap was invoked. An end-of-file will also cause the shell to exit except for a shell which has the ignoreeof option (See set below) turned on. return causes a shell function or '.' script to return to the invoking script with the return status specified by n. The value will be the least significant 8 bits of the specified status. If n is omitted then the return status is that of the last command executed. If return is invoked while not in a function or a '.' script, then it is the same as an exit. 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
break(1), csh(1), ksh(1), sh(1), attributes(5) SunOS 5.10 15 Apr 1994 exit(1)