[comp.unix.shell] Error trap/detection question in sh

dbert@mole.gnu.ai.mit.edu (Douglas Siebert) (04/03/91)

I have written a script in sh using named pipes to perform an unattended ftp
session.  I would like to insert some form of error checking/detection in it to
check for conditions such as "Network unreachable" and "Connection timed out"
etc.  I am using a command of the form:

ftp -n [address] < pipe > outfile &

where "pipe" is a named pipe created by "mknod pipe p"  I suppose I could add
something of the form 2>errorfile to trap errors and if the file is of positive
size assume something has occurred which I do not wish.  I am hoping for a
cleaner, better way though.  Any ideas?
--
________________________________________________________________________
Doug Siebert                                     dbert@gnu.ai.mit.edu
MBA Student (2nd year)
The University of Iowa

jik@athena.mit.edu (Jonathan I. Kamens) (04/04/91)

In article <1991Apr2.202116.15411@mintaka.lcs.mit.edu>, dbert@mole.gnu.ai.mit.edu (Douglas Siebert) writes:
|> where "pipe" is a named pipe created by "mknod pipe p"  I suppose I could add
|> something of the form 2>errorfile to trap errors and if the file is of positive
|> size assume something has occurred which I do not wish.  I am hoping for a
|> cleaner, better way though.  Any ideas?

  Get /pub/expect.shar.Z from ftp.uu.net, and write your script in expect
instead of trying to do it the way you are now; I suspect it'll be much
easier.  I believe you also need tcl to compile expect; tcl is available in
/pub/tcl.tar.Z on the same machine.

  If you want to find out what expect is all about, you can retrieve and print
out (after uncompressing it) the postscript file /pub/expect.ps.Z, which is
probably the paper that Don Libes presented about expect at a Usenix.

-- 
Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik@Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8085			      Home: 617-782-0710