- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- stdout redirect
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
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
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
тАО01-15-2002 12:48 AM
тАО01-15-2002 12:48 AM
stdout redirect
For example if I have direct the stdout to a file, can I redirect the stdout to a terminal later?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-15-2002 12:55 AM
тАО01-15-2002 12:55 AM
Re: stdout redirect
If you are saying that you redirected stdout by typing:
exec 1>filename
then to get it back to redirecting to the terminal, just type:
exec 1>/dev/tty
Rgds, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-15-2002 12:56 AM
тАО01-15-2002 12:56 AM
Re: stdout redirect
ie
pereal:root> who am i
root ttyp2 Jan 15 09:54
pereal:root> hello
---
pereal:root> who am i
root ttyp1 Jan 15 09:54
pereal:root>echo "hello" > /dev/ttyp2
pereal:root> ll /dev/ttyp2
cr-------- 2 root tty 17 0x000002 Jan 15 09:56 /dev/ttyp2
even when
pereal:root> mesg
is n
Later,
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-15-2002 01:12 AM
тАО01-15-2002 01:12 AM
Re: stdout redirect
#command | tee filename
like
#ll | tee file_list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-15-2002 05:38 PM
тАО01-15-2002 05:38 PM
Re: stdout redirect
Please read the example.
# backup > backup.log &
After running the command, can I make the stdout to other places such as tty when I have already assigned it to backup.log before and vice versa.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-15-2002 05:53 PM
тАО01-15-2002 05:53 PM
Re: stdout redirect
If I understand your question, you don't need to do anything.
backup > backup.log &
ls
echo "Test"
In this example, only stdout from the command backup will be redirected to stdout. The output
from the commands ls and echo "Test" will then appear on your terminal (assuming that your terminal is stdout). Notice also that since you dropped backup into the background that the next two commands execute immediately. If you are trying something like:
backup > backup.log &
backup2 > backup2.log &
backup3 > backup.log &
wait
echo "Test"
Then all three of the background commands must complete before wait allows the echo statement to execute.
Regards, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-15-2002 06:03 PM
тАО01-15-2002 06:03 PM
Re: stdout redirect
I should have said:
In this example, only stdout from the command backup will be redirected to the file 'backup.log'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-15-2002 06:27 PM
тАО01-15-2002 06:27 PM
Re: stdout redirect
# backup > backup.log
The stdout is redirected to backup.log
And now I want this existing redirection back to terminal (tty) again.
Can I do that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-15-2002 08:26 PM
тАО01-15-2002 08:26 PM
Re: stdout redirect
I'll try again because I don't think I understand your question.
backup > backup.log
In this case only the stdout from the command 'backup' is sent to the file backup.log but your terminal seems hung because it must wait for the command to complete. As soon as backup has finished, output to your terminal then resumes normally.
If you want to then send the contents of 'backup.log' to your terminal then that is nothing more than 'cat backup.log'. I think the best way to determine what you are doing is to experiment with a diffrent command that doesn't take so long to complete. I suggest that you temporarily substitute something like
'ls /tmp > backup.log' for you backup command just so you can get an idea of how to proceed.
Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-16-2002 06:52 PM
тАО01-16-2002 06:52 PM
Re: stdout redirect
It seems there is no way to do that and I must do this
# tail -f backup.log
I just want to make the stdout back to tty after I have submitted the command
# backup > backup.log &
so that the result as if I have submitted this command
# backup &
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-16-2002 11:30 PM
тАО01-16-2002 11:30 PM
Re: stdout redirect
I think if I you understand, you have to use the tee command like this:
backup | tee backup.log or
backup | tee backup.log &
Now your output is redirected to backup.log and also to tty.
I use often (for this example):
backup 2>&1 | tee backup.log
Hope this helps
Ruediger
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-17-2002 12:37 AM
тАО01-17-2002 12:37 AM
Re: stdout redirect
But I want it first redirect to a file, then later I want it back to tty.
Or can I transfer the stdout to another tty?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-17-2002 12:47 AM
тАО01-17-2002 12:47 AM
Re: stdout redirect
try this:
backup | tee backup.log >
Ruediger
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-17-2002 12:48 AM
тАО01-17-2002 12:48 AM
Re: stdout redirect
>> # backup > backup.log &
Note that if you want all errors to be recorded as well, you should log the STDERR as well:
# backup > backup.log 2>&1 &
>> But I want it first redirect to a file, then later I want it back to tty.
>> Or can I transfer the stdout to another tty?
To direct it back to the tty, run (as what Bill has mentioned):
# cat backup.log > /dev/ttyp0
If you want another tty say /dev/ttyp2, then:
# cat backup.log > /dev/ttyp2
If you want it to be displayed on your current login tty, then:
# cat backup.log
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-17-2002 01:09 AM
тАО01-17-2002 01:09 AM
Re: stdout redirect
*********************************
If you just "cat" the log file, then you are submitting another command to view the log file rather than re-redirect the stdout back to tty.
Also, if you use "cat", then you will not get further information from the log file since it may be kept updating. So using "tail -f" may be more appopriate.
*********************************
May be I am just thinking something that doesn't exist.
Thanks for all of you discussing this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-17-2002 01:19 AM
тАО01-17-2002 01:19 AM
Re: stdout redirect
Now I think I get what you mean. You want to pass control from a background process back to the foreground while being able to view the output of the process, yet log this output to a file.
Correct me if I am wrong.
In that case, then you should execute:
# backup | tee backup.log & # this will display output on the screen, log to a file while the backup continues running.
# fg # this will bring the backup process back up in the foreground for you to execute a ctrl-c to abort the backup.
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-17-2002 01:30 AM
тАО01-17-2002 01:30 AM
Re: stdout redirect
I want to transfer the stdout to a file or other tty.
And if another tty get the stdout, the result should be as if it is originally submitted from that tty.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-17-2002 01:48 AM
тАО01-17-2002 01:48 AM
Re: stdout redirect
your last answer confuses me.
You want to start and control your job from first tty and you need a additional output to a file or another tty. The output has to be the same. Isn't ??t?
And the job has to run in background or not.
If is so, I don't see the problem.
Ruediger