Hi Monks,
I've got a script that runs in the background on a linux box. It's basic job is to go log into a server and grab a list of files. What I DON'T want to happen is for the script to accidentally die when it tries to log in to a server but can't reach it (due to the server being down or having someone trip over the network cable). I'd like it to periodically check to see if the server is up and reachable, and do it's job if it is. If not, the script should just go to sleep for a while, wake up, and try again.
So my question is, what's the best way to check if a server is reachable using perl? If it matters, the server happens to be an FTP server and I'm currently using Net::FTP to get a directory list, but it might be an http server in the future. Is there a particular perl module I should use? Should I simply grab the output of a ping and parse for packets received? I can think of lots of ways, but was wondering if anyone who's done this sort of thing before had pointers.
Thanks monks!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.