grab shell script error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting grab shell script error
# 1  
Old 08-10-2012
grab shell script error

How do I capture an error for any command I use.

For e.g if i try to zip a file and the file is not there. The regualr $? -gt 0 only tells its un-successful but won't tell me that the file is not there when I run through a script. How can I capture this error?

for e.g.. zip $x.zip $x
file is not there

I need grab the return code as well as error in the script. How can I do that?
# 2  
Old 08-10-2012
Code:
command 2>errorfile

Change > to >> if required.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Calling shell script within awk script throws error

I am getting the following error while passing parameter to a shell script called within awk script. Any idea what's causing this issue and how to ix it ? Thanks sh: -c: line 0: syntax error near unexpected token `newline' sh: -c: line 0: `./billdatecalc.sh ... (10 Replies)
Discussion started by: Sudhakar333
10 Replies

2. Shell Programming and Scripting

Q: grab email username from script

Hi all, I want to set up a script to email a person to confirm another program is running but i wish to avoid having to customise the script for each individiual. I am ok with what i need to do except i need to get the first and last name of the user to construct an email address to send to.... (6 Replies)
Discussion started by: KlintJ
6 Replies

3. Shell Programming and Scripting

How to grab last column - Korn Shell

I need to grab the last column of data from each line of output from ps -ef | grep sshd Example: root 47645194 1703952 0 Oct 23 - 0:01 sshd: jcagle rnewmon 48694012 27984606 0 08:36:02 - 0:00 sshd: rnewmon@pts/292 Because some of these process have been out... (6 Replies)
Discussion started by: juredd1
6 Replies

4. Shell Programming and Scripting

Writing an snmp script to grab multiple oids at once

is it possible to grab the following oids with one invocation of the snmp command, instead of having to run separate commands: snmpwalk -v2c -c commst hostname hrStorageUsed snmpwalk -v2c -c commst hostname hrStorageDescr snmpwalk -v2c -c commst hostname hrStorageAllocationUnits ... (2 Replies)
Discussion started by: SkySmart
2 Replies

5. Shell Programming and Scripting

Syntax error calling TCL script from shell script

hello everyone i am beginner on shell scripting .and i am working on my project work on ad hoc network i wrote a batch (.sh) to do a looping and execute a tcl script i wrote before in each iteration ..but i got this problem " syntax error near unexpected token `('... (1 Reply)
Discussion started by: marcoss90
1 Replies

6. Shell Programming and Scripting

How to grep sql error in shell script and exit the script?

I need help in the following script. I want to grep the sql errors insert into the error table and exit the shell script if there is any error, otherwise keep running the scripts. Here is my script #!/bin/csh -f source .orapass set user = $USER set pass = $PASS cd /opt/data/scripts echo... (2 Replies)
Discussion started by: allinshell99
2 Replies

7. Shell Programming and Scripting

grab PID of a process and kill it in a script

#!/bin/sh who echo "\r" echo Enter the terminal ID of the user in use: echo "\r" read TERM_ID echo "\r" ps -t $TERM_ID | grep sh echo "\r" echo Enter the process number to end: echo "\r" read PID echo "\r" kill -9 $PID What this code does is ultimately grab the PID of a users sh... (6 Replies)
Discussion started by: psytropic
6 Replies

8. Windows & DOS: Issues & Discussions

DOS script to grab the first file in a dir and rename it

:confused: Hello, Is there any way to use the dir command / some DOS Script to select only first file of similar pattern of files in a direcotory and rename it for example, one directory has 5 files abc_1005.txt abc_5256.txt abc_2001.txt abc_2003.txt abc_3006.txt by use script I would... (2 Replies)
Discussion started by: raghav525
2 Replies

9. Shell Programming and Scripting

script to grab lines between two values

hi guys say I have a file that contains hello world this is AAAAA message to try BBBBBB and see if anyone AAAAA knows the (3 Replies)
Discussion started by: JamesByars
3 Replies

10. UNIX for Dummies Questions & Answers

awk Shell Script error : "Syntax Error : `Split' unexpected

hi there i write one awk script file in shell programing the code is related to dd/mm/yy to month, day year format but i get an error please can anybody help me out in this problem ?????? i give my code here including error awk ` # date-month -- convert mm/dd/yy to month day,... (2 Replies)
Discussion started by: Herry
2 Replies
Login or Register to Ask a Question