![]() |
version seven.   http://demongin.org |
Stupid Linux Tricks: Debug Your Website Like a Sysadmin
A few "tricks" used by sysadmins to quickly troubleshoot web development/deployment issues: use wget to view HTTP headers and telnet to view source.
Sunday, 2010-03-28 | AlmostEffortless, Careerism, On the Internet, Programming
I recently had a conversation with a certain programmer friend who, having foolishly overwritten his Firefox 3.0x with an installation of the 3.1 beta, was unable to use any of his plugins. This wasn't a huge problem for him--i.e. he figured he could live without his plugins for a week or two--until he realized that he wasn't going to be able to use LiveHTTPHeaders (http://livehttpheaders.mozdev.org/).
The plugin, which can greatly expedite client-side testing, is not the only way to do that sort of testing. In a pinch, you can view HTTP headers on the command line simply by firing up a terminal session and using wget:
$ wget -S almosteffortless.com -O /dev/null
toconnell@lana:~/tmp$ wget -S almosteffortless.com --2008-10-21 13:43:24-- http://tyrannybelle.com/ Resolving tyrannybelle.com... 208.78.99.165 Connecting to tyrannybelle.com|208.78.99.165|:80... connected. HTTP request sent, awaiting response... HTTP/1.1 200 OK Date: Tue, 21 Oct 2008 18:43:25 GMT Server: Apache/2.2.9 (Debian) PHP/5.2.6-5 with Suhosin-Patch mod_python/3.3.1 Python/2.5.2 mod_ssl/2.2.9 OpenSSL/0.9.8g X-Powered-By: PHP/5.2.6-5 Set-Cookie: PHPSESSID=aefe500683f79ed067f91f76d3615d33; path=/ Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Content-Length: 4932 Keep-Alive: timeout=15, max=100 Connection: Keep-Alive Content-Type: text/html Length: 4932 (4.8K) [text/html]
I showed this to my pal and, though he was a little impressed, he wasn't entirely convinced that he was going to be able to do all of his client testing using only the CLI: "yes, that's all fine and good", he said, "but I usually need to right-click and 'View Page Source' in order to check on dynamically generated content."
"You're not going to want to hear this," I responded, "but telnet is your friend on this one."
toconnell@lana:~/tmp$ telnet tyrannybelle.com 80
Granted, you don't get any syntax highlighting or fancy stuff, but if you're debugging from a mobile device, a computer without windowing software or in any other circumstance you can't use a proper browser, telnet is a great way to eyeball a website.
My friend admitted that this was, in fact, all right in a pinch, but it was plain from the look on his face that he still wasn't sold on ye olde command line as a testing/debugging tool. "What about layout?" he asked.
"Well yeah," I conceded, "there's really no good way to do that without a browser, but if you want to check on your tab order..."
