Hitting a URL from the command line
July 11, 2007 9:13 AM   Subscribe

Alternatives to lynx, wget and get from the unix command line?

I have a scheduled job that needs to hit a localhost URL once a day. Our servers don't have lynx or wget or get installed. Are there any alternatives? I've tried using telnet and Expect, and it works but when run through our scheduling app (Tivoli Workload Scheduler) I get a message "No environment-specified terminal type." even when I specify the terminal type. So I was wondering if there are other techniques I could try.
posted by Null Pointer and the Exceptions to Computers & Internet (11 answers total)
 
Do you have a compiler installed? I would try to compile wget from source. It's bound to be useful in the future as well.
posted by demiurge at 9:25 AM on July 11, 2007


curl. Or perl. Or python. Probably Ruby, too.

That said... wget is usually pretty easy to build/install locally if you have a shell and a compiler (./configure --prefix=/home/you/local or something like that, make, make install), so I usually do.
posted by namespan at 9:27 AM on July 11, 2007


$ man bash # and search for "socket"
posted by cmiller at 9:32 AM on July 11, 2007


Assuming Perl is installed, you can install HTTP::Client locally and do

perl -MHTTP::Client -e 'print HTTP::Client->new()->get("http://localhost/path")'
posted by nicwolff at 9:33 AM on July 11, 2007


nicwolff, i'll call your HTTP::Client and raise you an LWP:
perl -MLWP::Simple -e 'get("http://www.metafilter.com/")'
posted by jozxyqk at 9:35 AM on July 11, 2007


'lwp-request' is the perl answer. Fabulously useful tool, that.

I use 'lwp-request -Sexd' for a variety of tests, and also because it's easy to remember.
posted by jquinby at 9:36 AM on July 11, 2007


Whoops, throw a -l/home/you/lib (or whatever) in there if you've installed HTTP::Client under your user dir.
posted by nicwolff at 9:38 AM on July 11, 2007


Yeah, I'd normally use LWP since it's installed here, but if it's not it's a lot to install just to make a simple HTTP request...
posted by nicwolff at 9:39 AM on July 11, 2007


Ah, also see if 'netcat' is installed. If it is, you can do something like this:

nc -v www.somewebsite.com 80

...and pass it "GET / HTTP/1.0\r\r"
posted by jquinby at 9:41 AM on July 11, 2007


PHP is also an option:

php -r "file('http://metafilter.com/');"
posted by scottreynen at 11:18 AM on July 11, 2007


if it's a BSD, there's a chance you'll have fetch installed. Worth a quick check, unless you're just working with a seriously stripped down server.
posted by Arturus at 9:46 PM on July 11, 2007


« Older What's Fun On Puget Sound?   |   privacy waiver for work? Newer »
This thread is closed to new comments.