|
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
|