- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: script output to both log file and to my scree...
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
02-02-2004 02:18 AM
02-02-2004 02:18 AM
script output to both log file and to my screen window..
>
> LOGDIR=/var/opt/timefinder/logs
> SCRIPT=$(basename $0 .ksh)
> BCVSET=$1
> LOGDATE=$(date +%m%d%y-%H%M)
> LOG=${LOGDIR}/${SCRIPT}_${BCVSET}.${LOGDATE}.log
> exec 2>${LOG}
> exec >&2
>
> (script commands)
>
So, all of the script output goes to $LOGDIR/script_name_date.log
But, when I run the script manually (to test changes, etc), I want the output to go to my screen window (and to the log file..)..
Can I do something, in the script, like:
> exec 1>${LOG} 2>&1 tee "screen window"
Stuart
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2004 02:25 AM
02-02-2004 02:25 AM
Re: script output to both log file and to my screen window..
from man
SYNOPSIS
tee [-i] [-a] [file] ...
DESCRIPTION
The tee command transcribes the standard input to the standard output
and makes copies in the files
EXAMPLES
Write a list of users to the screen and also append the list to the
file hunt:
who | tee -a hunt
Thus
command 2>&1|tee -a $LOG
Steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2004 02:26 AM
02-02-2004 02:26 AM
Re: script output to both log file and to my screen window..
exec 2>&1 | tee -a ${LOG}
This displays to screen, and appends to the log.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2004 02:27 AM
02-02-2004 02:27 AM
Re: script output to both log file and to my screen window..
Try with removing the exec commands from the script. When you want the output to log file only:
script >logfile
To screen AND logfile:
script | tee -a logfile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2004 02:27 AM
02-02-2004 02:27 AM
Re: script output to both log file and to my screen window..
Can't think of a quick way to do exactly what you ask, but how about?
tail -f $LOGDIR/script_name_date.log
-- Graham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2004 02:30 AM
02-02-2004 02:30 AM
Re: script output to both log file and to my screen window..
my suggestion would be:
> exec 2>&1 | tee -a ${LOG}
Michael