[comp.unix.questions] Can Telnet input come from two sources?

frank@hpuxa.ircc.ohio-state.edu (Frank G. Fiamingo) (07/04/90)

I'm trying to setup a front end for the Telnet program for use
by novices.  They'll be telneting to various hosts that presents them
with several menu's.  I'd like to get them through the menu's by
taking telnet's input from a file, then have the input switch
to stdin.  Can this be done?  If so, how?

I'm doing this on an HP9000/840  running HP-UX7.0.

Thanks,
Frank

-=-
Frank Fiamingo
frank@hpuxa.ircc.ohio-state.edu
(614)292-4843

david@csource.oz.au (david nugent) (07/05/90)

In <2516@nisca.ircc.ohio-state.edu> frank@hpuxa.ircc.ohio-state.edu (Frank G. Fiamingo) writes:

>I'm trying to setup a front end for the Telnet program for use
>by novices.  They'll be telneting to various hosts that presents them
>with several menu's.  I'd like to get them through the menu's by
>taking telnet's input from a file, then have the input switch
>to stdin.  Can this be done?  If so, how?


Not a file, but it could be taking it from a pipe from another
process.  That process could then freopen() stdin to /dev/ttyXX
if it knew the controlling terminal (or just /dev/tty if it happened
to have the same one).

BTW, I've never tried this exactly; but this is the first tack I'd
take in attempting to solve the problem.

-- 
_______________________________________________________________________________
 Unique Computing Pty Ltd  Melbourne  Australia  -  Communications Specialists 
        david@csource.oz.au    3:632/348@fidonet    28:4100/1@signet           

sahayman@iuvax.cs.indiana.edu (Steve Hayman) (07/06/90)

>I'm trying to setup a front end for the Telnet program for use
>by novices.  

Get the program 'expect', by Don Libes, available for ftp from
durer.cme.nist.gov .  This program was written up in the most recent
Usenix proceedings - I think it will do what you want.  expect
can be used to control interactive programs such as telnet - you can
have it feed telnet some lines from a file, and then switch
telnet's input so it comes from the user.  Sounds like just what
you need.

Here's the README file:
    This is the README file from "expect", a program that performs
    programmed dialogue with other interactive programs.  It is briefly
    described by its man page, expect(1).  More examples and further
    discussion about implementation, philosophy, and design are in
    "expect: Curing Those Uncontrollable Fits of Interaction" by Don
    Libes, Proceedings of the Summer 1990 USENIX Conference, Anaheim,
    California, June 11-15, 1990.

    expect was designed and written by Don Libes, January - April, 1990.

    Design and implementation of this program was paid for by U.S. tax
    dollars.  Therefore it is public domain.  However, the author and NIST
    would appreciate credit if this program or parts of it are used.

    expect may be ftp'd as pub/expect.shar.Z from durer.cme.nist.gov.  If
    you cannot ftp, you may request email copies by mailing to "library@
    cme.nist.gov".  The contents of the message should be (no subject
    line) "send pub/expect.shar.Z".  Once you have retrieved the system,
    please read the INSTALL file.  The paper mentioned above can be ftp'd
    separately as pub/expect.ps.Z.

    expect requires Tcl.  Tcl may be ftp'd as pub/tcl.tar.Z from
    ucbvax.berkeley.edu.  If not available, a potentially older but
    working version of Tcl may be ftp'd as pub/tcl.tar.Z from
    durer.cme.nist.gov.  If you cannot ftp, you may request email copies
    of Tcl by writing to ouster@sprite.berkeley.edu.

    expect is known to work on SunOS 4.0 systems but it does nothing Sun
    specific and will probably work on most BSD-derived systems.  While
    it has not been compiled on SV or POSIX systems, I have made
    provisions enough so that probably only minor changes remain.  (See
    the Makefile for more info.)  This might be presumptive however, as I
    recently looked at the process control in gnuemacs and am amazed how
    much pain it took them to make it portable.  Perhaps someday I will
    change to using their code.  I would be willing to work with you to
    complete a port.

    Although I can't promise anything in the way of support, I'd be
    interested to hear about your experiences using it (either good or
    bad).  I'm also interested in hearing bug reports (please include
    version # reported by expect -d) and suggestions for improvement even
    though I can't promise to implement them immediately.

    Please send money, love letters, and bug reports to:

    Don Libes
    National Institute of Standards and Technology
    Bldg 220, Rm A-127
    Gaithersburg, MD  20899
    (301) 975-3535
    libes@cme.nist.gov   or   uunet!cme-durer!libes


Hope this helps.
..steve
-- 
Steve Hayman    Workstation Manager    Computer Science Department   Indiana U.
sahayman@iuvax.cs.indiana.edu                                    (812) 855-6984