sub fail { # Allow failures to show on the web page. print @_; exit 0; } foreach $wmlfile (@fileftp) { if(-f $wmlfile) { $ftp_commands = " open $remotehost1 user $remoteuser $remotepass cd $remotepath asc put $wmlfile bye "; open (CMD, "|$cmd") or fail "Can't fork() to run $cmd ($wmlfile): $!\n"; print CMD $ftp_commands or fail "Can't write commands to $cmd ($wmlfile): $!\n"; close (CMD) or fail "$cmd ($wmlfile) failed? ($?): $!\n"; print "File $wmlfile has been transferred \n"; print "
\n"; $finish = 'transfer'; copy ($wmlfile,"./$finish/$wmlfile") or fail "Can't save $wmlfile to $finish: $!\n"; } }