Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Check server status remotely with a perl script' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Check server status remotely with a perl script
Authored by: mistersquid on Mar 01, '06 05:03:33AM

Pete, I appreciate your pointing to a standard UNIX utility to do this work, but your post reeks of programmer's laziness. Not only do you refer everyone to the "man" page for nc, but you provide no further details.

I'm moderately experienced issuing commands at the CLI, though I don't program in the shell. Like many, I program in PERL (or some other non-shell scripting language) and then execute from the command line. The beauty is I don't have to figure out the idiosyncrasies of every UNIX utility out there.

Would you mind explaining to those of us who do not program at the command line how one might use the functionality of nc to take some kind of action once a connection establishes or fails to establish?

From what I can tell, nc is interactive and the only way to do this as an automated task is to have a non-shell interface querying using nc.



[ Reply to This | # ]
Check server status remotely with a perl script
Authored by: foilpan on Mar 01, '06 11:00:42AM

i didn't interpret the previous post with any sort of hostility or "programmer's laziness," as you did.

since i'm not that familiar with netcat's usage, it took a minute or two of quick man page reading to see what it does. that's not so bad.

for instance, i just issued a <code>nc -vz 192.168.1.1 1-80</code> to scan the open ports on our main server here in the office (that's not the internal IP, but you get the idea). it works like a charm, showing which ports are open. If you try with a host that's down, it will report as such. neat-o.

i've used nmap to test for hosts' status, too.



[ Reply to This | # ]
Check server status remotely with a perl script
Authored by: rschwarz on Mar 01, '06 12:17:01PM
Thank you foilpan for your additional information on the usage of nc. Although I looked up the man page, it was not instantly clear to me, that this can be done so easily.

You can also set the timeout with the -w option. This is useful to me, since I don't want to wait a minute or so until netcat aborts.

[ Reply to This | # ]