Redhat Linux 7.2 telnet can't take input from file

Redhat Linux 7.2 telnet can't take input from file

Post by Raymond Chu » Wed, 17 Apr 2002 21:44:43



I have Redhat Linux 7.2 running bash 2.05
Normally in UNIX you can do

command < filename
or
command << EOF
do more commands
.....
EOF

For example
ftp ftp.host.domain << EOF
ftp

cd pub
bin
get filename
quit
EOF

Now I want to do automation get a Web page by

telnet www.host.domain 80
GET /cgi-bin/myprogram.pl HTTP/1.0
<CR>

where <CR> is a carriage return or Enter.
This is working fine for me. But now I want to put it in a ksh or bash
script file

telnet www.host.domain 80 << EOF
GET /cgi-bin/myprogram.pl HTTP/1.0
<CR>
EOF

It is not work at all!!!
But I run this script in HP-UX 10.20 on both ksh and bash, it works
fine!!

I also try create a file contain lines GET command and <CR>, then do
telnet www.host.domain 80 < filename

It doesn't work neither in Redhat Linux 7.2, but work fine in HP-UX
10.20!!!

So this seems to me Redhat 7.2 telnet either has bug or need to do some
setup.
Can anyone out there help me?
Thank Q very much in advance!

  raymond.chui.vcf
< 1K Download
 
 
 

Redhat Linux 7.2 telnet can't take input from file

Post by Steffen Klug » Wed, 17 Apr 2002 23:12:04



Quote:>Normally in UNIX you can do

>command < filename

Yes, if command reads from stdin.

Quote:>telnet www.host.domain 80 << EOF
>GET /cgi-bin/myprogram.pl HTTP/1.0
><CR>
>EOF

>It is not work at all!!!
>But I run this script in HP-UX 10.20 on both ksh and bash, it works
>fine!!

That's a surprise to me. Normally, telnet insists on reading from
a terminal device. That's why things like expect were created.

Either check out expect, which lets you script telnet and ftp
sessions, or use netcat, which is more appropriate when talking
to a web server, anyway.

Cheers
Steffen.

 
 
 

Redhat Linux 7.2 telnet can't take input from file

Post by Grant Edwar » Thu, 18 Apr 2002 00:08:41



>>telnet www.host.domain 80 << EOF
>>GET /cgi-bin/myprogram.pl HTTP/1.0
>><CR>
>>EOF
[...]
> Either check out expect, which lets you script telnet and ftp
> sessions, or use netcat, which is more appropriate when talking
> to a web server, anyway.

or use wget, whose purpose in life is to fetch web pages.

--
Grant Edwards                   grante             Yow!  Just imagine you're
                                  at               entering a state-of-the-art
                               visi.com            CAR WASH!!

 
 
 

Redhat Linux 7.2 telnet can't take input from file

Post by Garry Knigh » Thu, 18 Apr 2002 01:41:32



> use wget, whose purpose in life is to fetch web pages.

or httrack, or curl.

--
Garry Knight

Linux registered user 182025