🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.unix.shell
11 messages
11 total messages Started by Shiping Zhang Fri, 12 Oct 1990 02:58
standard input to commands in a shell script
#1476
Author: Shiping Zhang
Date: Fri, 12 Oct 1990 02:58
13 lines
853 bytes
When I invoke the following script, the process always pauses at
the password prompt. I have to hit the return key to make it
proceed. I don't know what's the problem. Do you have the same
problem if you try it? I'm working on a Sun-3 with os4.1. I appreciate
it if anyone can point out the problem for me. Thanks.

# cut here 
ftp genbank.bio.net << END
ftp
ident
ls
quit
END
Re: standard input to commands in a shell script
#1477
Author: Don Libes
Date: Fri, 12 Oct 1990 16:37
30 lines
1407 bytes
In article <1990Oct12.025833.13376@cubmol.bio.columbia.edu> ping@cubmol.bio.columbia.edu (Shiping Zhang) writes:
>When I invoke the following script, the process always pauses at
>the password prompt. I have to hit the return key to make it
>proceed. I don't know what's the problem. I appreciate
>it if anyone can point out the problem for me.

>ftp genbank.bio.net << END
>ftp
>ident
>ls
>quit
>END

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.  An easy and general approach is to use expect.
Here's an expect script that will do what you want.

spawn ftp genbank.bio.net
expect "*Name*:*"
send "ftp\r"
expect "*Password:"
send "ident\r"
expect	"*failed*ftp>*" exit \
	"*logged*in*ftp>*"
send "ls\r"
expect "*ftp>*"
send "quit\r"

Don Libes          libes@cme.nist.gov      ...!uunet!cme-durer!libes
Re: standard input to commands in a shell script
#1479
Author: Bruce Barnett
Date: Fri, 12 Oct 1990 17:31
28 lines
1323 bytes
>   In article <1990Oct12.025833.13376@cubmol.bio.columbia.edu> ping@cubmol.bio.columbia.edu (Shiping Zhang) writes:

>>ftp genbank.bio.net << END
>>ftp
>>ident
>>ls
>>quit
>>END

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 <<END
user anonymous $HOST
get pub/file $temp
quit
END
--
Bruce G. Barnett	barnett@crd.ge.com	uunet!crdgw1!barnett
Re: standard input to commands in a shell script
#1480
Author: Michael Meissner
Date: Fri, 12 Oct 1990 19:28
37 lines
1752 bytes
In article <BARNETT.90Oct12133123@grymoire.crd.ge.com>
barnett@grymoire.crd.ge.com (Bruce Barnett) writes:

| >   In article <1990Oct12.025833.13376@cubmol.bio.columbia.edu>
| > ping@cubmol.bio.columbia.edu (Shiping Zhang) writes: 
| 
| >>ftp genbank.bio.net << END
| >>ftp
| >>ident
| >>ls
| >>quit
| >>END
| 
| 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 <<END
| user anonymous $HOST
| get pub/file $temp
| quit
| END

(echo "user anonymous"; echo "${USER-${LOGNAME}}@`hostname`"; echo dir; echo quit) | \
	ftp uunet.uu.net
--
Michael Meissner	email: meissner@osf.org		phone: 617-621-8861
Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142

Do apple growers tell their kids money doesn't grow on bushes?
Re: standard input to commands in a shell script
#1481
Author: Bruce Barnett
Date: Fri, 12 Oct 1990 19:43
11 lines
1092 bytes
In article <MEISSNER.90Oct12152854@osf.osf.org> meissner@osf.org (Michael Meissner) writes:

>   (echo "user anonymous"; echo "${USER-${LOGNAME}}@`hostname`"; echo dir; echo quit) | \
>	   ftp uunet.uu.net

Try:

 (echo "user anonymous ${USER-${LOGNAME}}@`hostname`"; echo dir; echo quit) | \
	   ftp uunet.uu.net
--
Bruce G. Barnett	barnett@crd.ge.com	uunet!crdgw1!barnett
Re: standard input to commands in a shell script
#1483
Author: Booker bense
Date: Fri, 12 Oct 1990 23:25
30 lines
1207 bytes
In article <1990Oct12.025833.13376@cubmol.bio.columbia.edu> ping@cubmol.bio.columbia.edu (Shiping Zhang) writes:
>When I invoke the following script, the process always pauses at
>the password prompt. I have to hit the return key to make it
>proceed. I don't know what's the problem. Do you have the same
>problem if you try it? I'm working on a Sun-3 with os4.1. I appreciate
>it if anyone can point out the problem for me. Thanks.
>
># cut here 
>ftp genbank.bio.net << END
>ftp
>ident
>ls
>quit
>END

Ftp reads the password from /dev/tty there's no simple way to get
around this , however I would suggest you read the man page on netrc.
It allows you to put ftp in scripts.

-Booker C. Bense


/* benseb@grumpy.sdsc.edu */






.line fodder 
Re: standard input to commands in a shell script
#1494
Author: Jonathan I. Kamens
Date: Sun, 14 Oct 1990 15:24
46 lines
2461 bytes
In article <BARNETT.90Oct12133123@grymoire.crd.ge.com>, 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 <<END
|> 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
Re: standard input to commands in a shell script
#1495
Author: Jonathan I. Kamens
Date: Sun, 14 Oct 1990 15:29
16 lines
1393 bytes
In article <BARNETT.90Oct12154348@grymoire.crd.ge.com>, barnett@grymoire.crd.ge.com (Bruce Barnett) writes:
|> In article <MEISSNER.90Oct12152854@osf.osf.org> meissner@osf.org (Michael Meissner) writes:
|> >   (echo "user anonymous"; echo "${USER-${LOGNAME}}@`hostname`"; echo dir; echo quit) | \
|> >	   ftp uunet.uu.net
|>  (echo "user anonymous ${USER-${LOGNAME}}@`hostname`"; echo dir; echo quit) | \
|> 	   ftp uunet.uu.net

  Neither of these examples will work, unless you supply "-n" option to ftp. 
Bruce, you got that right in your original posting on this subject, but forgot
it here :-).

-- 
Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik@Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8495			      Home: 617-782-0710
Re: standard input to commands in a shell script
#1496
Author: Bruce Barnett
Date: Mon, 15 Oct 1990 13:57
17 lines
1287 bytes
In article <1990Oct14.152950.29384@athena.mit.edu> jik@athena.mit.edu (Jonathan I. Kamens) writes:

>Neither of these examples will work, unless you supply "-n" option to ftp. 
>Bruce, you got that right in your original posting on this subject, but forgot
>it here :-).

Termcap! Foiled again! The script I sent by E-mail worked.

A lowly wizard was at the bottom of a 1000 foot well. Each posting to
USENET that is unique and correct allows the wizard to climb up three
feet. Each mistake or redundant posting causes the wizard to slide
back two feet........


Well, at least I gained a foot. :-)
--
Bruce G. Barnett	barnett@crd.ge.com	uunet!crdgw1!barnett
Re: standard input to commands in a shell script
#1497
Author: Shiping Zhang
Date: Mon, 15 Oct 1990 17:47
9 lines
966 bytes
In response to my post on the subject, many people either posted
on this group or mailed me directly. Their messages are very helpful
to me. I'm very grateful to their help. The posts have covered all
I got from email, so I'm not going to post a summary here, assuming
all of you who are interested in this subject read all the posts.
If anyone feels missing something, please mail to me, I'll mail
back whatever I know. Thanks again.

-ping
Re: standard input to commands in a shell script
#1516
Author: Pierre Rogier
Date: Mon, 15 Oct 1990 18:52
25 lines
1216 bytes
In article <1990Oct12.025833.13376@cubmol.bio.columbia.edu>,
ping@cubmol.bio.columbia.edu (Shiping Zhang) writes:
|> When I invoke the following script, the process always pauses at
|> the password prompt. I have to hit the return key to make it
|> proceed. I don't know what's the problem. Do you have the same
|> problem if you try it? I'm working on a Sun-3 with os4.1. I appreciate
|> it if anyone can point out the problem for me. Thanks.
|> 
|> # cut here 
|> ftp genbank.bio.net << END
|> ftp
|> ident
|> ls
|> quit
|> END

ftp read passwd from /dev/tty and not from standard input

I use the following script :
ftp -n my_machine <<END
user ftp ident
ls
quit
END
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads