Need shell script help

| techie stuff | | Comments (8)

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?

8 Comments

dave said:

Dude, tell him to open the purse and spring for Mercury Interactive Sitescope if her wants to monitor a web page or site.

Lisa said:

Ha! Our sysadmins told him that he couldn't/shouldn't use Sitescope for that.

don said:

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..

Andy said:

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 sad

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.

Curator said:

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.

Mark Gardner said:

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.

About this Entry

This page contains a single entry by Lisa published on December 2, 2004 12:31 PM.

December already? was the previous entry in this blog.

Wow! is the next entry in this blog.

Find recent content on the main index.

Me!

Happiness is not the absence of problems but the ability to deal with them.—Anonymous

About me... :: memes :: My Amazon wishlist :: My LJ :: My Twitter :: My Flickr :: Photos of me

Blog reading list

Contacts
· AIM, Yahoo!, MSN, Google Talk, LJ Talk... just ask
· Email me

Good Causes

       
Love is love.
Support gay marriage.

platinum.gif
East siiiiiiiiiiiiiiiiiiiide, baby!
Click to help
sponsor mammograms
Listen to good music! Radio Paradise

Silly Stuff

blogchalk:
Lisa/Female/41-45. Lives in United States/Mass/Boston and speaks
English. Spends 80% of daytime online. Uses a Faster (1M+) connection.
The
WeatherPixie
The weather in Boston

Flickr

www.flickr.com
jasra's photos More of jasra's photos
Powered by Movable Type 4.1

Copyright

Copyright © 2001-7 Lisa K Holsberg. Unauthorized use is prohibited.