Operating System - HP-UX
1833758 Members
2781 Online
110063 Solutions
New Discussion

sending http from shell script

 
SOLVED
Go to solution
Richard Mertz
Regular Advisor

sending http from shell script

Anyone know how to send an http request from a shell script?

Richard
What anybody thinks of me is none of my business.
5 REPLIES 5
James R. Ferguson
Acclaimed Contributor

Re: sending http from shell script

Richard:

See if this meets your needs:

http://www.shelldorado.de/scripts/cmds/urlencode.txt

...JRF...
Dan Hetzel
Honored Contributor

Re: sending http from shell script

Hi Richard,

As HTTP is plain ASCII text, you may use any 'echo' or 'print' statement to create an HTTP request or even a full HTML page.
To simplify coding, you may also use the 'here-document' mechanism like in
print << EOF
...
Your HTML code here
...
EOF

Type 'man sh-posix' and search for '<<' for details about the 'here-document'

Best regards,

Dan
Everybody knows at least one thing worth sharing -- mailto:dan.hetzel@wildcroft.com
Rainer_1
Honored Contributor

Re: sending http from shell script

If you want to get a http page from the internet you could use wget to send a http request.

Look at:

http://hpux.cs.utah.edu/hppd/hpux/Gnu/wget-1.5.3/

Richard Mertz
Regular Advisor

Re: sending http from shell script

OK, I should have been more specific. I am running a package that indexes our web site for searching. This works great for us for having the box index itself (it's in the DMZ). I would like to automagically produce an internal index that includes the web site in the DMZ. Because we are running websense (requires firewall login to get outside) I must somehow automatically log in to the firewall prior to running the indexing program. Websense generates a login screen after the first http request. So...I would like to send a bogus http request, followed by a login string. So, the first question I have is how do I echo something to the http port (80 in this case).

Richard
What anybody thinks of me is none of my business.
Dave Kelly_1
Respected Contributor
Solution

Re: sending http from shell script

You need to use telnet for this.

telnet hostname 80 < /tmp/input.script

where /tmp/input.script contains something like

GET / HTTP/1.0

followed by a blank line.