Detail: It's a script that does many things including using Net::FTP to download some files over an extremely unreliable connenction. As a result, the Net::FTP session occasionally dies with an error like: "Timeout at /usr/local/lib/perl5/site_perl/5.6.0/Net/FTP.pm line 471" That's ok. I expect it to happen. It could also die for other reasons than a time out. Also note that the script uses lock files, and a bunch of other stuff that gets cleaned up in sig handler. e.g.
So, what I want to happen is to somehow have the script know if it died because Net::FTP timed out or for some other reason. If it was due to a time out, I want to restart the script. Possible solutions I've thought of for restarting it: use backticks or system() to execute the script from another script that restarts it, turn the existing script into a sub and call it from another script, etc. What I'd really like to do is have the signal handler in the script itself check this condition and restart itself. (i.e. a self resurrecting script) That avoids having an extra script to keep track of. Is this possible? Another problem is that I don't know how to tell what caused the script to 'die'. I looked at $? and it seems to be the same value no matter what caused the die. Is there a way to find out if Net::FTP caused it to die or if it was one of my own 'die' statements? I only want to restart for a time out condition, not any other error condition.$SIG{__DIE__} = \&handle_die;
Any thoughts are welcome! Thanks,
--RT
PS -- yes, I know I can set the Timeout value in Net::FTP but that doesn't solve the problem. When the link goes down, it's down for a while.
Matthew 28:5-6, NIV
In reply to Self resurrecting perl scripts by RhetTbull
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |