Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

stderr redirection

Status
Not open for further replies.

zyrag

IS-IT--Management
Dec 4, 2002
252
0
0
PH
hi, how do i redirect stderr to a log file and at the same time display the error message at the console?

This is the first time i work with scripting. Part of my script below worked to redirect the error message but to display the same at the console is what i don't know how.

tar -cvf /dev/rmt0 /file1 /file2 2>> backup.log

Also, how will i trap if an error exists so i could have and If-Then-Else statement to display successful or unsuccessful backup?

thanks,
 
thanks mokano, it works great. but, if i only want to log the associated errors, how will i do it?

Also, how will i know if a tape media has been inserted or not into the tape drive?

thanks again.
 
Use the mt command to check for media.
eg, mt -f /dev/rmt0 rewind
 
zyrag,

use

tar -cvf /dev/rmt0 /file1 /file2 >> backup.log 2>&1

 
thanks nathans for your help. I think i should continue using the command `tar -cvf /dir 2>>$HOME/backup.log` so that only the errors are logged and yet retaining the ouput to be displayed at the console. The user won't understand anyway about the errros that might occur.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top