- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- exec to direct the output to a file
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2004 09:11 AM
07-15-2004 09:11 AM
It will be put in the beging of my script(ksh), then all output of the script will go to /tmp/outputfile.
Please help.
thanks,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2004 09:15 AM
07-15-2004 09:15 AM
Re: exec to direct the output to a file
This wil redirect the stdout and stderr to /tmp/out.log
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2004 09:25 AM
07-15-2004 09:25 AM
Re: exec to direct the output to a file
It did direct the output to the file, but what if meanwhile I also want the output displayed on the screen at same time?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2004 09:31 AM
07-15-2004 09:31 AM
Re: exec to direct the output to a file
set -xv
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2004 09:37 AM
07-15-2004 09:37 AM
Re: exec to direct the output to a file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2004 09:39 AM
07-15-2004 09:39 AM
Re: exec to direct the output to a file
(
) 2>&1 | tee -a /tmp/log
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2004 10:04 AM
07-15-2004 10:04 AM
Re: exec to direct the output to a file
This goes in the script,
exec >logfile 2>&1 | tee
or still another way,
# ./script &
# tail -f logfile
regds,
Abdul.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2004 10:10 AM
07-15-2004 10:10 AM
Re: exec to direct the output to a file
But still this would be a workaround,
#./myscript; tail -f /tmp/outfile
regds,
Abdul.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2004 04:27 PM
07-15-2004 04:27 PM
Re: exec to direct the output to a file
If you start the script(s) with set -x or set -v it will give the debugging of commands execution. If you are running only one command as exec .. then put that command in a script file with the set -x or set -v. Execute the script and traverse all the ouput's and error's to a common log file.
IF want to log all operations that are going to be done,then use script or tee command.
If you want to append the messages in a common log file use -a with script or tee command. Use tee more instead of script because it will log some control characters like ^M for removing operational characters.
script will run upto stopping that command. tee will be stopped after the completio n or termination of command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2004 12:51 AM
07-16-2004 12:51 AM
Re: exec to direct the output to a file
For example:
su - prdadm -c "rdist -f $DRPDIR/distfile prdadm"; ) 2>&1 | tee $DRPDIR/drp.log 2>&1 | mailx -s "PRDADM DRP rdist output" gwild@mydomain.com
That will put it in the drp.log file as well as email me.
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2004 06:42 AM
07-16-2004 06:42 AM
Re: exec to direct the output to a file
But what if I want the log file name to be "/tmp/log.dateandtime",there is command can change the log file name and put the data and time at the end of the log fiile name. What is that command?
thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2004 06:47 AM
07-16-2004 06:47 AM
Solution(
) | tee /tmp/log.$(date "+%d%b%y")
modify the date command to have the date format as you would like. refer man date.
The above command will name the log file as for ex. /tmp/log.16Jul04
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2004 02:10 PM
07-17-2004 02:10 PM
Re: exec to direct the output to a file
/tmp/log.$$
you can list the runs and find the time of the file creations.
ls -l /tmp/log.*
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2004 01:50 AM
07-18-2004 01:50 AM
Re: exec to direct the output to a file
If you use the "exec >$(logfile) 2>&1" method, you can make this as a standard header in most scripts and append/create logiles the you wanted.
I do keep something like this as a header, which is very much reusable.
logdir=/var/adm/log
script=`basename ${0)`
date=`date "+%d-%b-%y:%H:%M"`
logfile=${logdir}/${script}.${date}.log
exec >>${logfile} 2>&1
(
script
)