[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 254
  • Last Modified:

telnet not working with file input

We want to get an HTML page as a file in UNIX. It worked when we type "telnet foo.bar.com 80 http/1.0" then in telnet "GET /whatever/thing?arg<CR><CR>". However, if we put the GET command into a file (with 2 blank lines for the <CR>s) and then go "telnet foobar 80 http/1.0 < cmdfile" , then 9 times out of ten the page stops half way (when the CGI on the other end start to look things up). The task then hangs, until I press ^Z, then telnet exits. That is so strange. Why does it work manually but not when the command is in a file? And why would ^Z end it while ^C wouldn't?? thanks!
0
tpchai
Asked:
tpchai
1 Solution
 
tpchaiAuthor Commented:
Edited text of question
0
 
ozoCommented:
Do you have expect(1) on your system?
If so, you could control a telnet script with that.
If not you might try the Net::Telnet module in Perl.
Or else use some other URL grabbing prog, e.g.
(echo $username; echo $password) | request 'http://www.experts-exchange.com/topics/bin/ShowQ?qid=8630013784'
0
 
tpchaiAuthor Commented:
We have neither the expect nor request commands on our system (system V release 4.0) The Net::telnet module in Perl; is that a library with Perl 5? I am only a casual user of Perl 4.
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
ozoCommented:
I think it is Perl5, (as are some modules which duplicate expect,
and the request program)
But it looks like there may be a Perl4 version at
http://www.ics.uci.edu/pub/websoft/libwww-perl/
http-get looks like it may be Perl4 too.
Can you upgrade to Perl5?
(that's probably worth doing regardless of the resolution of
this problem)
It looks like there are other non-perl utilities to get html
pages too, maybe `netscape -remote`?
 

0
 
julio011597Commented:
Hello,

AFAIK, the problem is that you should NOT telnet to a web server, since the telnet protocol involves some negotiation.

So, you may still telnet to a web server for testing purposes, but you are not guaranteed that that would work.

To get a page, you should write a simple client program which makes a socket connection to the web server.

Regards, julio
0
 
bkcCommented:
This problem has nothing to do with telnet option negotiation as suggested by julio. Telnet clients are 'mum' until they receive a telnet option from the telnet 'server'.

If they do not receive such an option, they operate in 'line mode'.

My suggestion is to get lynx for your system. Lynx is rather popular and you can probably get it precompiled.

You can use the lynx -dump option to send the output to a file.

0
 
tpchaiAuthor Commented:
Although julio's message doesn't actually answer why it's doing that, we are going to write a program with sockets, as suggested also by our sys admin (who is going to do it.) Lynx was an option I had considered, so thanks also to bkc for suggesting the -dump option (which I didn't know of.)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now