The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
run shell script from oracle store procedure arnabb4u Shell Programming and Scripting 8 08-16-2006 09:16 AM
How to run an SQL script inside a shell stevefox Shell Programming and Scripting 1 06-15-2006 07:11 PM
How to run unix commands in a new shell inside a shell script? hkapil Shell Programming and Scripting 2 01-04-2006 02:56 AM
Using tar inside a shell script kas7225 Shell Programming and Scripting 2 05-19-2005 08:06 PM
Store return code of shell script in oracle table sveera Shell Programming and Scripting 3 05-04-2005 10:25 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-19-2008
Registered User
 

Join Date: Mar 2008
Posts: 36
How to store the outputs of a shell script inside a log file???

My shell script file name is test.sh and the contents of this test.sh file are

Code:
ps_file="package1.ps"
echo $ps_file
ps_file1=`echo $ps_file| sed "s/.ps//g"`
echo $ps_file1
ps2pdf -dSAFER -sPAPERSIZE=a4 /tmp/A380_RFS24/amm_r0_ps/$ps_file1.ps /tmp/A380_RFS24/amm_r0_pdf/$ps_file1.pdf
Now i want to store the output of this test.sh file in test.log file.

For this i have written the following command

Code:
test.sh > test.log
But i don't want to store the output like the above methods.

Can i do this one like the following ways????
Code:
ps_file="package1.ps"
echo $ps_file > test.log
ps_file1=`echo $ps_file| sed "s/.ps//g"`
echo $ps_file1 > test.log
ps2pdf -dSAFER -sPAPERSIZE=a4 /tmp/A380_RFS24/amm_r0_ps/$ps_file1.ps /tmp/A380_RFS24/amm_r0_pdf/$ps_file1.pdf > test.log

Last edited by Yogesh Sawant; 03-20-2008 at 03:23 AM. Reason: added code tags
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-19-2008
Registered User
 

Join Date: Mar 2008
Posts: 24
use the redirection operator >> instead of >

eg: ls -ltr >> abc will throw all the outout to abc and the next time when you do
pwd >> abc
the previous output willl be appened to the new output

Hope this answers your question..

Thanks

Antony cecil
Reply With Quote
  #3 (permalink)  
Old 03-20-2008
Registered User
 

Join Date: Mar 2006
Location: Mumbai
Posts: 67
You may use the following in ur script ...

Code:
logfile=test.log
ps_file="package1.ps"
echo $ps_file
ps_file1=`echo $ps_file| sed "s/.ps//g"`
echo $ps_file1
ps2pdf -dSAFER -sPAPERSIZE=a4 /tmp/A380_RFS24/amm_r0_ps/$ps_file1.ps /tmp/A380_RFS24/amm_r0_pdf/$ps_file1.pdf

exec 1>${logfile}
exec 2>&1


This will redirect the standard o/p(indicated by 1) and standart error ( indicated by 2) to the test.log file.
Hope this helps !!
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 10:54 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0