my $un = 'username@domain.com; my $pw = 'password'; print "- FTPing report... "; my $ftp; my $status = 1; my ($connectattempts, $putattempts, $cwdattempts, $loginattempts) = (0,0,0,0); STARTFTP: $ftp = Net::FTP->new("host.com", Debug => 0, Passive => 0) or $status = 0; if (!$status) { if ($connectattempts < 3) { $connectattempts++; print "Session failed, retrying in 60 seconds\n"; $status = 1; sleep 60; goto STARTFTP; } else { goto FAILED; } } $status = $ftp->login($un,$pw); if (!$status) { if ($loginattempts < 3) { $loginattempts++; print "Login failed, retrying in 60 seconds\n"; $status = 1; sleep 60; goto STARTFTP; } else { goto FAILED; } } $ftp->binary(); $status = $ftp->put($outputfile,$outputfile); if (!$status) { if ($putattempts < 3) { $putattempts++; print "PUT command failed, retrying in 60 seconds\n"; $status = 1; sleep 60; goto STARTFTP; } else { goto FAILED; } } $ftp->quit; print "$file successfully uploaded.\n"; unlink $file; return 1; FAILED: print "$file was not transferred to host.com! Please upload manually!\n\n"; return 0; }