LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-07-2008, 11:16 AM   #1
debuser123
Member
 
Registered: Nov 2006
Distribution: Ubuntu Hardy
Posts: 69

Rep: Reputation: 15
Question Redirecting standard out/err mid-process?


Is there a way to redirect stdout/stderr after a process has already started (using bash)? For example,

1) suspend with ctrl+z
2) __fill_in_the_blank__
3) resume with bg or fg

Thanks
 
Old 08-08-2008, 06:01 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
You can attach to a running process with strace but you can't redirect stdout/stderr after a process has already started. If you would have been able to "play" with file descriptors that way then a lot of problems would have ensued where processes expect an fd to be connected to a terminal, file, socket or pipe and not have it changed halfway through to say the bitbucket.
 
Old 08-08-2008, 11:23 AM   #3
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,126
Blog Entries: 2

Rep: Reputation: 124Reputation: 124
http://etbe.coker.com.au/2008/02/27/...nning-process/
 
Old 08-08-2008, 07:52 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
That's neat.
 
Old 08-09-2008, 12:42 AM   #5
debuser123
Member
 
Registered: Nov 2006
Distribution: Ubuntu Hardy
Posts: 69

Original Poster
Rep: Reputation: 15
Thanks for the link; I didn't think that it would be that involved...I seem to assume that with linux/unix there's always a command to do something...you just need to know what that command is.

But thanks for the info, I could write up a script to accomplish what I've asked. Not sure of the reliability or scalability but it's a start.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Redirecting non-standard file descriptors gd2shoe Programming 9 04-09-2007 05:48 AM
Dual system boot err: rootnoverify(hd1,0),but the hd0 err msg existed befor shut down lilipeng24 Linux - General 3 06-25-2005 12:10 PM
how to redirecting the standard output in program phil123 Linux - General 3 02-23-2004 12:02 AM
Redirecting process output to shell mhelles Linux - Newbie 1 04-30-2003 09:30 AM
standard vs Expert install? Standard flubs up! Frost Linux - Software 1 03-27-2002 07:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration