Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!snorkelwacker!bloom-beacon!athena.mit.edu!jik From: jik@athena.mit.edu (Jonathan I. Kamens) Newsgroups: comp.unix.shell Subject: Re: standard input to commands in a shell script Message-ID: <1990Oct14.152441.29291@athena.mit.edu> Date: 14 Oct 90 15:24:41 GMT References: <1990Oct12.025833.13376@cubmol.bio.columbia.edu> Sender: daemon@athena.mit.edu (Mr Background) Reply-To: jik@athena.mit.edu (Jonathan I. Kamens) Organization: Massachusetts Institute of Technology Lines: 46 In article , barnett@grymoire.crd.ge.com (Bruce Barnett) writes: |> In article <7219@muffin.cme.nist.gov> libes@cme.nist.gov (Don Libes) writes: |> >The problem is that ftp (as do most programs) reads passwords from |> >/dev/tty, ignoring your i/o redirection. There is no shell mechanism |> >to get around this. |> News to me. I have always done this, which works fine. |> |> set HOST=`hostname` |> set SOURCE=machine.edu |> set temp=/tmp/file |> ftp -n $SOURCE < user anonymous $HOST |> get pub/file $temp |> quit |> END Don is correct when he says that there is no *shell* mechanism to get around the problem of a program forcing a read from /dev/tty. However, you are correct when you point out that there is an *ftp* mechanism for getting around the problem of *ftp in particular* forcing a read from /dev/tty -- just invoke ftp with auto-login disabled (the -n option) and then supply the password with the "user" command, so that ftp never prompts for it. The other ftp mechanism for getting around the problem is to use a .netrc files. Two other mechanisms for getting around the problem are using Don's "expect" program (whose use he illustrated in his posting) and using Dan Bernstein's "pty" program. Personally, I'd choose pty in this particular case, not because it's more fault-tolerant than expect (in this case, it isn't), but rather because the original poster's shell script can be made to work with no other modifications simply by changing this line: ftp genbank.bio.net << END to this line: pty ftp genbank.bio.net << END -- Jonathan Kamens USnail: MIT Project Athena 11 Ashford Terrace jik@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8495 Home: 617-782-0710