use IPC::Run3; $url = "ftp://10.0.0.3"; $ftpUser = "ftpuser"; $ftpPass = "ftp"; $sleepSec = 60; sub runWget() { my ($stdout, $stderr); my @args = ("wget", "-O", "nul", "-r", "-v", "--user=$ftpUser", "--password=$ftpPass", $url); IPC::Run3::run3(\@args, undef, \$stdout, \$stderr); $r = $?; open FILE, ">last-stdout" or die; print FILE $stdout; close FILE; open FILE, ">last-stderr" or die; print FILE $stderr; close FILE; return $r; } $iter = 1; while(1) { my ($r); $r = runWget; if ($r) { print("\nError!\n"); exit 1; } print "Iteration #$iter completed\n"; $iter++; sleep($sleepSec); }