![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Error file Redirection | maxmave | Shell Programming and Scripting | 3 | 04-23-2008 12:17 PM |
| redirection | DNAx86 | Shell Programming and Scripting | 9 | 04-18-2008 02:24 PM |
| sed redirection | myle | UNIX for Dummies Questions & Answers | 3 | 03-12-2008 07:04 PM |
| Redirection or piping error message | mariner | Shell Programming and Scripting | 2 | 05-10-2005 03:04 PM |
| Help with redirection | Shallon1 | High Level Programming | 2 | 12-12-2001 07:35 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
error redirection
i am using 2> to redirect all the standard errors that i get in my bash script.. this command needs to be given in all the statements for which the errors are to redirected..
is there a command that will catch all the errors in all the shell commands that are present inside a script .? pls help.. |
|
||||
|
hi era
exec 2>/path/to/stderr.log .... this command seems to be like an alternate for using -x when we run a script.... it directs not just the error but all the commands and the step wise execution for that program.... i would like to redirect only the standard errors of all the commands in a program .... any idea for that .. |
|
||||
|
hi era ,
what i mentioned there was we giving sh -x filename.sh gives us step wise execution of the program and if i give exec 2>path/file inside a script ... and when i open the file that is getting created it contains a step wise execution of the program... this is what i give in the script... #!bin/sh cd /NRS #exec 2>error_$tar_name.log sql_inp=/NRS/sql.inp sql_log=/NRS/sql.log if [ -f /NRS/inp.txt ] then echo "Data file /NRS/Bin/inp.txt exists" else echo "Data file /NRS/Bin/inp.txt does NOT exists" exit fi # to remove comments from the file inp.txt grep -v \# /NRS/inp.txt > /NRS/temp_inp nol=`wc -l temp_inp | awk '{print$1}'` if [ $nol -ne 2 ] then echo "supply all the necessary arguements in the inp.txt file " else tar_name=`head -1 temp_inp | tail -1` ip_addr=`head -2 temp_inp | tail -1` #usr=`head -3 temp_inp | tail -1` #pwd=`head -4 temp_inp | tail -1` fi log=/NRS/$tar_name.log etc.... and when i open the error_$tar_name.log : + [ -f /NRS/inp.txt ] + echo Data file /NRS/Bin/inp.txt exists + grep -v # /NRS/inp.txt + awk {print$1} + wc -l temp_inp nol=2 + [ 2 -ne 2 ] + tail -1 + head -1 temp_inp tar_name=star_nrs_4_25_0.tar.Z + head -2 temp_inp what i had asked was whether can i redirect only the stderrors that i might get .... becoz this is a very big program and has some where around 600 commands that i need to perform so instead of giving 2> at the end of each command can i redirect all of them at one go ... thanks |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|