Operating System - Linux
1830061 Members
2677 Online
109998 Solutions
New Discussion

use telnet to retrieve web page in script

 
SOLVED
Go to solution
Charles Li_1
Advisor

use telnet to retrieve web page in script

I have use the following in HP-UX and it works:
++++++++++++++++++++++++
telnet server port <GET /page
EOF
++++++++++++++++++++++++
In HP-UX it displays the content of the page.
But in Linux, it does not. What do I need to change to make it work in Linux. I am using RedHat. Thanks.
6 REPLIES 6
Alexander Chuzhoy
Honored Contributor

Re: use telnet to retrieve web page in script

telnet servername port
GET http://site/page



works fine on my redhat

Huc_1
Honored Contributor
Solution

Re: use telnet to retrieve web page in script

Try wget

best read man wget first

Tell us if you need more

J-P
Smile I will feel the difference
Mark Grant
Honored Contributor

Re: use telnet to retrieve web page in script

I don't understand why this works at all in anything. The http protocol requires you send a get , the url and the HTTP version and the hostname before you get any response from teh server.

Perhaps you could tell us how it isn't working but try sending a string like this

GET /page HTTP/1.1\nHost: $HOSTNAME\n\n
Never preceed any demonstration with anything more predictive than "watch this"
Charles Li_1
Advisor

Re: use telnet to retrieve web page in script

Thanks. wget works. I was using the telnet in a script, and it did not work. Thanks for all your replies.
Stuart Browne
Honored Contributor

Re: use telnet to retrieve web page in script

Mark, A HTTP in it's most bastardised way can be used as above. If following protocol you need other bits and pieces.

Charles, using wget is your best option (or using 'lynx -source'), but the reason your telnet routne didn't work is because it was exiting as soon as it had sent the string.

The trick to doing that sort of thing with telnet is to 'sleep' for a while to await the response. Please note however that this is a truely dumb way to do it :P But it can be done. e.g.

( echo "GET /page"; sleep 5 ) | telnet host port
One long-haired git at your service...
Charles Li_1
Advisor

Re: use telnet to retrieve web page in script

.