Discussion Locked
0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I have written a script that has a subroutine that moves some files via FTP. The problem is that sometimes the FTP server is down. This causes the program to die. I am trying to add fault tolerance to the program, but haven't been able to get thesubroutine to just return gracefully to the calling routine. I have tried an unless($ftp->login...){return 0} but it doesn't seem to work. Any ideas on putting putting some error handling on the ftp call would be greatly appreciated
3 replies
by gspecht
I recently had a similar problem.. I created a function to 'ping' the server and return true or false if the server respnded to the ping. This avoids trying to logon to a non-responcive server.
by gjohnson
This doesn't help. Although it may ping, that doesn't mean that the connect will occur. The problem is that I have a bad connect, the entire program abends. I recently figured out the problem. I put the subroutine call in an "eval { &subroutine }; " block, then the "die" statements in the subroutine don't kill the calling program, I get a nicely formatted error message at $@ that you can print out.
Thanks for your help anyway.
George
by gjohnson
This question was closed by the author
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending
Discussion Locked
What Makes a Business Website Effective in 2026
2 helpful
10 replies
1 helpful
3 replies
Question
Windows and macOS computers becoming slow or unstable after updates - what should I check first
0 helpful
1 reply
Question Unanswered
Best Way to Make Long WordPress Location Guides Mobile Friendly
0 helpful
0 replies
Discussion
Optimizing WordPress widgets and DOM size
0 helpful
3 replies