New xterm and stdout redirection

New xterm and stdout redirection

Post by Frédéric Mayo » Sat, 07 Feb 2004 18:40:50



Hi,

I wonder if this was possible : in my script, I launch many processes in
background and I'd like to see the output in different terminals.

example:
for file in $files; do
   #launch xterm
   my_prog $file > to_the_new_xterm &
done

Do you have other ideas ? How can I do this ?

Thanks a lot.

Fred

 
 
 

New xterm and stdout redirection

Post by Christophe Le Ga » Sat, 07 Feb 2004 20:45:45



Quote:> example:
> for file in $files; do
>    #launch xterm
>    my_prog $file > to_the_new_xterm &
> done

> Do you have other ideas ? How can I do this ?

xterm -e my_prog $file &
?

 
 
 

New xterm and stdout redirection

Post by Kenny McCorma » Sun, 08 Feb 2004 00:41:08





>> example:
>> for file in $files; do
>>    #launch xterm
>>    my_prog $file > to_the_new_xterm &
>> done

>> Do you have other ideas ? How can I do this ?

>xterm -e my_prog $file &
>?

I actually faced and solved a version of this recently.

The idea is that you have a process running in the current shell, and it
generates various bits of terminal output that you don't want to lose (have
vanish), but then you reach a point where a particular piece of the process
generates a lot of output such that you would ordinarily run it through
a pager.  But the problem is that the pager takes over the screen and
blasts away the previous contents (*).  So, what I do is (something like):

mkfifo /tmp/apipe
xterm -e less -f /tmp/apipe &
...
someprocess > /tmp/apipe
...

You might want to try something like this.

(*) Yes, I knew that some terminal types address this by having an
"alternate screen", but that doesn't always work and doesn't fully solve
the issue (when it does work).

 
 
 

New xterm and stdout redirection

Post by Stephane CHAZELA » Sun, 08 Feb 2004 00:48:02


2004-02-06, 15:41(+00), Kenny McCormack:
[...]
Quote:> mkfifo /tmp/apipe
> xterm -e less -f /tmp/apipe &
> ...
> someprocess > /tmp/apipe

[...]

Note that you can avoid the named pipe by using an unnamed one
and a fd above 2:

someprocess | xterm -e sh -c 'less <&3' 3<&0

--
Stphane                      ["Stephane.Chazelas" at "free.fr"]

 
 
 

New xterm and stdout redirection

Post by Stephane CHAZELA » Sun, 08 Feb 2004 00:49:07


2004-02-06, 15:41(+00), Kenny McCormack:
[...]

Quote:> (*) Yes, I knew that some terminal types address this by having an
> "alternate screen", but that doesn't always work and doesn't fully solve
> the issue (when it does work).

Note that if your terminal doesn't have an alternate screen, you
can still have one using GNU screen.

--
Stphane                      ["Stephane.Chazelas" at "free.fr"]

 
 
 

New xterm and stdout redirection

Post by Kenny McCorma » Sun, 08 Feb 2004 01:48:09




Quote:>2004-02-06, 15:41(+00), Kenny McCormack:
>[...]
>> mkfifo /tmp/apipe
>> xterm -e less -f /tmp/apipe &
>> ...
>> someprocess > /tmp/apipe
>[...]

>Note that you can avoid the named pipe by using an unnamed one
>and a fd above 2:

>someprocess | xterm -e sh -c 'less <&3' 3<&0

Nope.
 
 
 

New xterm and stdout redirection

Post by Stephane CHAZELA » Sun, 08 Feb 2004 03:27:22


2004-02-06, 16:48(+00), Kenny McCormack:
[...]

Quote:>>> mkfifo /tmp/apipe
>>> xterm -e less -f /tmp/apipe &
>>> ...
>>> someprocess > /tmp/apipe
>>[...]

>>Note that you can avoid the named pipe by using an unnamed one
>>and a fd above 2:

>>someprocess | xterm -e sh -c 'less <&3' 3<&0

> Nope.

Which version of xterm is it? Does your version of xterm close
every fd (before assigning 0, 1 and 2 and starting less)? Does
someprocess get a SIGPIPE?

Here it works with xterm XFree86 4.3.99.15(180).

--
Stphane                      ["Stephane.Chazelas" at "free.fr"]

 
 
 

New xterm and stdout redirection

Post by Kenny McCorma » Sun, 08 Feb 2004 04:26:18




Quote:>2004-02-06, 16:48(+00), Kenny McCormack:
>[...]
>>>> mkfifo /tmp/apipe
>>>> xterm -e less -f /tmp/apipe &
>>>> ...
>>>> someprocess > /tmp/apipe
>>>[...]

>>>Note that you can avoid the named pipe by using an unnamed one
>>>and a fd above 2:

>>>someprocess | xterm -e sh -c 'less <&3' 3<&0

>> Nope.

>Which version of xterm is it? Does your version of xterm close
>every fd (before assigning 0, 1 and 2 and starting less)? Does
>someprocess get a SIGPIPE?

>Here it works with xterm XFree86 4.3.99.15(180).

To quote Willy boy Clinton, "It depends on what the meaning of the word
'works' is."
 
 
 

New xterm and stdout redirection

Post by Stephane CHAZELA » Sun, 08 Feb 2004 04:44:43


2004-02-06, 19:26(+00), Kenny McCormack:
[...]

Quote:>>>>> mkfifo /tmp/apipe
>>>>> xterm -e less -f /tmp/apipe &
>>>>> ...
>>>>> someprocess > /tmp/apipe
>>>>[...]

>>>>Note that you can avoid the named pipe by using an unnamed one
>>>>and a fd above 2:

>>>>someprocess | xterm -e sh -c 'less <&3' 3<&0
[...]
>>Here it works with xterm XFree86 4.3.99.15(180).

> To quote Willy boy Clinton, "It depends on what the meaning of the word
> 'works' is."

I guess I have not understood what you wanted to achieve. So, to
summarize what I say:

With my version of xterm

mkfifo /tmp/apipe
xterm -e less -f /tmp/apipe &
someprocess > /tmp/apipe

and

someprocess | xterm -e sh -c 'exec less <&3' 3<&0

work exactly the same (except for the shell message for the job
being run in background, and the (unwanted) fifo created in /tmp
[probably with world reading permissions]).
That's all and I'm not going to try any harder to guess what you
exactly meant by "Nope".

--
Stphane                      ["Stephane.Chazelas" at "free.fr"]

 
 
 

New xterm and stdout redirection

Post by Kenny McCorma » Sat, 27 Mar 2004 06:39:18




Quote:>2004-02-06, 16:48(+00), Kenny McCormack:
>[...]
>>>> mkfifo /tmp/apipe
>>>> xterm -e less -f /tmp/apipe &
>>>> ...
>>>> someprocess > /tmp/apipe
>>>[...]

>>>Note that you can avoid the named pipe by using an unnamed one
>>>and a fd above 2:

>>>someprocess | xterm -e sh -c 'less <&3' 3<&0

>> Nope.

>Which version of xterm is it? Does your version of xterm close
>every fd (before assigning 0, 1 and 2 and starting less)? Does
>someprocess get a SIGPIPE?

>Here it works with xterm XFree86 4.3.99.15(180).

Actually, I just got around to testing this some more today, and found that
it does indeed work (on Solaris) with xterm, but not with rxvt.  rxvt seems
to be broken in this regard.  rxvt is my preferred "xterm work-alike".
 
 
 

New xterm and stdout redirection

Post by Stephane CHAZELA » Sat, 27 Mar 2004 07:52:21


2004-03-25, 21:39(+00), Kenny McCormack:
[...]

Quote:>>>>someprocess | xterm -e sh -c 'less <&3' 3<&0
[...]
> Actually, I just got around to testing this some more today, and found that
> it does indeed work (on Solaris) with xterm, but not with rxvt.  rxvt seems
> to be broken in this regard.  rxvt is my preferred "xterm work-alike".

rxvt closes every fd before running the command (including fd
3). That seems to be a "feature". I don't know the reason for
that behavior, though.

--
Stphane                      ["Stephane.Chazelas" at "free.fr"]

 
 
 

1. redirecting STDOUT of a bg process to STDOUT of a new xterm

I often start a background process in an xterm and then kill the xterm.
The
process is still running on the machine but it's tty is "?"

Is there a way to redirect this process so that it becomes a job on a
new
xterm?

I want to see what gets printed to STDOUT of this process.

Thanks.

--

**************************************************************
Mike Green                              Intel Corp

ph (602) 552-3428                       5000 W. Chandler Blvd.
fax (602) 554-6006                      Chandler, AZ  85226
**************************************************************
****************My opinions are strictly my own***************

2. UMSDOS, WIN95, LINUX

3. redirection: stdout to one file, stderr to other file, and both to screen

4. KMail: Multiple Addresses

5. Temporary stdin/stdout redirection

6. Consider this Topic Closed

7. stdout redirection, and piping

8. HELP: NFS mount hangs when attempting to copy file

9. bash redirection stdout and stderr - pipeline command causes subshell execution

10. Lost Assignment of var in shell for loop with stdout redirection

11. redirection of one stream to two files (eg: file and stdout)

12. stderr & stdout - Redirection

13. Can I get back stdout after redirection?