[comp.unix.programmer] Two paths for one file descriptor

wmark@wb3ffv.ampr.org (Mark Winsor) (02/18/91)

I need the ability within a curses based program to be able to send the 
standard output to two different terminals upon receipt of a SIGUSR1. The
purpose of this is to enable remote viewing via modem of what a user is 
doing WITHOUT requiring them to get out of the application. Anybody have
any suggestions? I realize that most solutions will require that the
local and remote terminals are the same type (which is not a problem). Any
ideas would be appreciated.

Thanks,
Mark S. Winsor
ProVAR, Inc.

libes@cme.nist.gov (Don Libes) (02/20/91)

In article <3814@wb3ffv.ampr.org> wmark@wb3ffv.ampr.org (Mark Winsor) writes:
>I need the ability within a curses based program to be able to send the 
>standard output to two different terminals upon receipt of a SIGUSR1. The
>purpose of this is to enable remote viewing via modem of what a user is 
>doing WITHOUT requiring them to get out of the application. Anybody have
>any suggestions? I realize that most solutions will require that the
>local and remote terminals are the same type (which is not a problem). Any
>ideas would be appreciated.

If you have expect (see comp.unix.questions FAQ), you can do this with
the following script:

	trap {log_file another-terminal} SIGUSR1
	spawn curses-based-program
	interact

You can jam this all on the command line without the script as:

	expect -c "trap {log_file file} SIGUSR1; spawn program; interact"

Don Libes          libes@cme.nist.gov      ...!uunet!cme-durer!libes

staceyc@sco.COM (Stacey Campbell) (02/21/91)

In article <3814@wb3ffv.ampr.org> wmark@wb3ffv.ampr.org (Mark Winsor) writes:
>I need the ability within a curses based program to be able to send the 
>standard output to two different terminals upon receipt of a SIGUSR1.

If you mean one process sending output to two different terminals, and
you are using System V 3.2 curses then check out the routines;

	SCREEN *newterm(type, outfd, infd)

which sets up curses for output to a new terminal, and

	SCREEN *set_term(new)

which makes curses switch to the new terminal.

>The purpose of this is to enable remote viewing via modem of what a user is 
>doing WITHOUT requiring them to get out of the application. Anybody have
>any suggestions? I realize that most solutions will require that the
>local and remote terminals are the same type (which is not a problem). Any
>ideas would be appreciated.

The above solution supports terminals of different types.

p.s. it helps if people mention what operating system they are using,
a lot of BSD systems still do not provide System V curses functions
(however many proprietary BSD based systems now ship the latest System V
curses libraries).
-- 
                             Stacey Campbell       
                        Internet: staceyc@sco.com
     UUCP: {uunet,ucscc,att,sq,altos,lotus,sun,microsoft}!sco!staceyc