Need shell script help
My manager is trying to write a shell script (don't ask). He wants to:
1) telnet to port 80
2) send a GET request
3) see if the results say "Success"
Anyone have any hints for him?
My manager is trying to write a shell script (don't ask). He wants to:
1) telnet to port 80
2) send a GET request
3) see if the results say "Success"
Anyone have any hints for him?
Dude, tell him to open the purse and spring for Mercury Interactive Sitescope if her wants to monitor a web page or site.
Ha! Our sysadmins told him that he couldn't/shouldn't use Sitescope for that.
You want an 'expect' script. Expect is a shell extension, so you can tell it to perform a certain action, and based on the criteria, perform additional actions..
You could probably use wget to do it..
I've done this. telnet on sunos used to be good for scripting, but the solaris version isn't as nice
I've done it in VB with sockets.
I've tweaked someone else's expect (mentioned by Don above) script - it is related to tcl/tk, and be very nice for handling odd errors.
As it is a web page (port 80), wget (metioned by Andy above) can be nice to script. I use wget in cygwin scripts with my blog.
I'm sure it wouldn't be too hard in Java with sockets if needed.
Try something along these lines:
:
telnet www.benpadilla.info 80 | egrep "200 OK" <<EOF
GET /About.asp HTTP/1.0
EOF
if [ $? -eq 0 ]; then
echo Success
else
echo Failure
fi
Cheers.
curl, wget, or even lynx can do this in one line.
Er, the simplest answer is the use GET.
[ '200 OK' = "`GET -s -d bannister.us`" ] && echo 'Oh Goodie, it works'
If your boss is on Windows the Cygwin distribution includes GET as well.