- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- ksh: How do I turn "exec >file" redirect off?
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
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
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
тАО03-11-2004 08:26 AM
тАО03-11-2004 08:26 AM
...exec 2>${LOG}
...exec >&2
How do I "turn this off", so that I can write messages to "stdout" without them being logged and so I can see them when the script runs..
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-11-2004 08:36 AM
тАО03-11-2004 08:36 AM
Re: ksh: How do I turn "exec >file" redirect off?
#..exec 2>${LOG}
#..exec >&2
then stdout and stderr will go to where they were directed prior to the exec, hopefully that will be your terminal
or you could try something like this
exec 2>&1
tee -a /${LOG} >/dev/console |&
exec 1>&p
which will send everything to your log and to the system console.
or a little more complex
tty=$(tty)
exec 2>&1
tee -a /${LOG} >$tty |&
exec 1>&p
which hopefully will send everything to the log and to your termial
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-11-2004 08:38 AM
тАО03-11-2004 08:38 AM
Re: ksh: How do I turn "exec >file" redirect off?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-11-2004 09:16 AM
тАО03-11-2004 09:16 AM
Re: ksh: How do I turn "exec >file" redirect off?
At the end of the script, after 1000 lines have been sent to the $LOG, I then want to "disable" logging to $LOG, and write "Ending 'scriptname'." on "stdout".
How do I disable the redirect at the end of the script just to squeeze out one line to "stdout".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-11-2004 09:18 AM
тАО03-11-2004 09:18 AM
Re: ksh: How do I turn "exec >file" redirect off?
exec 2>$LOG >&2
....
echo to the log file
....
exec 2>&4 >&5 4>&- 5>&-
echo to the stdout
It is better than use of /dev/tty because it really restore the real output
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-11-2004 09:26 AM
тАО03-11-2004 09:26 AM
Re: ksh: How do I turn "exec >file" redirect off?
make a backup of the file descriptors
exec 4>&2 5>&1 # backup the filedescr of 1 and 2
exec 2>$LOG >&2
then when you want to print to your terminal
print -u5 "this is what I want to see on the screen"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-11-2004 09:26 AM
тАО03-11-2004 09:26 AM
SolutionAnother method. You could create a "copy" of the original stdout to a different file descriptor, then print you messages to it.
# create copy of stdout on descriptor 5
exec 5>&1
# change stdout to go to the log
exec 1>${LOG}
# print text to your term
print -u5 "some text to the screen"
That will allow the normal output from other commands in your script to go to the log, yet allow you to print stuff to the screen by using "print -u5".
--
Tony
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-11-2004 09:36 AM
тАО03-11-2004 09:36 AM
Re: ksh: How do I turn "exec >file" redirect off?
echo ... >&5
the advantage of dupping back the 4 and 5 to 2 and 1 is that it closes the log file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-11-2004 09:50 AM
тАО03-11-2004 09:50 AM
Re: ksh: How do I turn "exec >file" redirect off?
Stuart