Discussion Locked

Perl and FTP

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

This discussion is closed to new replies.