[comp.unix.shell] Why does this work?

phillips@CMSUN.NRL.NAVY.MIL (Lee Phillips) (02/05/91)

I can do an automated FTP transfer of a list of files by including the
appropriate list of commands in a file, called f, and typing (in csh)
ftp remotehost < f.
FTP then prompts me for my password before reading the commands from
f (my username is in the .netrc file, but not my password).  This is 
just what I want, but why does it work?  How does FTP know not to
look in f for my password?  

                                           Lee Phillips
                                           phillips@cmf.nrl.navy.mil
                                           phillips@fozzie.nrl.navy.mil
                                           phillips@lcp.nrl.navy.mil

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

In article <9102042103.AA16650@cmsun.nrl.navy.mil>, phillips@CMSUN.NRL.NAVY.MIL (Lee Phillips) writes:
|> FTP then prompts me for my password before reading the commands from
|> f (my username is in the .netrc file, but not my password).  This is 
|> just what I want, but why does it work?  How does FTP know not to
|> look in f for my password?  

  Ftp, like most programs that prompt for password, opens /dev/tty, flushes
input from it, and then reads the password from it, rather than reading the
password from stdin.

  In fact, it probably uses the getpass(3) library function.

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