[comp.unix.internals] Controlling ftp via a pipe: using pty's on a pipe

libes@cme.nist.gov (Don Libes) (09/06/90)

In article <1990Sep5.034248.2458@cs.umn.edu> wisdom@pico.cs.umn.edu (Scott Wisdom) writes:
>I am writting an application which needs to interactively control an
>ftp session. To do this, I have set up two pipes (an input and an output 
>...
>I can't find out how to do this. I've looked up everything I can think of
>in the manuals, consulted various advanced unix programming books, and
>even searched through usr/include. I can't find a lead anywhere...
>I'm out of ideas. HELP! Does anyone have any ideas on how to do this???!

You haven't looked hard enough.  In the most recent USENIX proceedings,
there is a paper describing how to solve this problem. The paper is
"expect: Curing Those Uncontrollable Fits of Interaction".

The software 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.

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

gt0178a@prism.gatech.EDU (BURNS,JIM) (09/06/90)

in article <6256@muffin.cme.nist.gov>, libes@cme.nist.gov (Don Libes) says:
>                                The paper mentioned above can be
> ftp'd separately as pub/expect.ps.Z.

This paper, when uncompressed, turns out to be a FrameMaker 2.0 file. I
think this is a PC program. At any rate, I don't have it. Is there a plain
text version, or Nroff, or Tex? Thanx.
-- 
BURNS,JIM
Georgia Institute of Technology, Box 30178, Atlanta Georgia, 30332
uucp:	  ...!{decvax,hplabs,ncar,purdue,rutgers}!gatech!prism!gt0178a
Internet: gt0178a@prism.gatech.edu

rowe@cme.nist.gov (Walter Rowe) (09/07/90)

>>>>> On 5 Sep 90 03:42:48 GMT, wisdom@pico.cs.umn.edu (Scott Wisdom) said:

Scott> I am writting an application which needs to interactively
Scott> control an ftp session.

I suggest you get a program developed here at NIST called `expect',
which allows you write shell-script-like code to interact with
programs that are normally user-interactive.  You `expect' some given
set of regular expressions, and give a set of actions to perform
depending on which of those regular expressions `expect' sees from the
program (ie. the "*ftp>" prompt, or the "*login: " prompt).

This program can be retrieved via anon ftp from durer.cme.nist.gov
(129.6.32.4) under ~ftp/pub/expect.shar.Z.  You may also have to get
the file tcl.tar.Z as well, since `expect' is uses the tcl (Tool
Command Language) library.  There is also a paper written about expect
called `expect.ps.Z'.  I suggest reading that, too.

Believe me, this will be much simple than writing all the C code
yourself, and expect can interact with *any* interactive program.
It has a relatively extensive man page, and the TCL man page is very
useful as well.  It comes with several example scripts, including one
for ftp and one that makes two chess(6) processes play against each
other.

Scott> Many thanks in advance to those who can help a frustrated
Scott> programmer who's running out of hair to pull.

I would encourage your sending thanks to Don Libes (libes@cme.nist.gov)
if you get `expect' as he is the author.

Scott> Scott Wisdom
Scott> wisdom@heckle.cs.umn.edu

wpr
---
Walter P. Rowe                                    ARPA: rowe@cme.nist.gov
System Administrator, Robot Systems Division      UUCP: uunet!cme-durer!rowe
National Institute of Standards and Technology    LIVE: (301) 975-3694