I have been trying to get a PHP script working where it downloads roughly 300 files from one FTP server and then moves them to another but a random number has been downloaded it errors (At least it seems random). The code for the script is
<?php
$HOST="XXXXX";
$UN="XXXX";
$PW="XXXX";
$DIR="/orangebox/garrysmod/cache/dua/";
$conn = ftp_connect($HOST);
if(!$conn) {
exit("Could not connect to server: $HOST\n");
}
if(!ftp_login($conn,$UN,$PW)) {
ftp_quit($conn);
exit("Could not log in\n");
}
ftp_pasv($conn, false);
ftp_chdir($conn,$DIR);
$files = ftp_nlist($conn,".");
for($i=0;$i<count($files);$i++) {
usleep(500000);
if(!ftp_get($conn,$files[$i],$files[$i],FTP_ASCII)) {
echo "Could not download {$files[$i]}\n";
}
print `bzip2 -f $files[$i]`;
}
ftp_quit($conn);
?>
The errors I keep getting are
Warning: ftp_get() [function.ftp-get]: Opening data channel for file transfer. in /home/tridentb/public_html/meow/garrysmod/cache/dua/duaUpdate.php on line 26
Could not download ./b549618303.dua
Warning: ftp_get() [function.ftp-get]: Can't open data connection. in /home/tridentb/public_html/meow/garrysmod/cache/dua/duaUpdate.php on line 26
Could not download ./b559542695.dua
Warning: ftp_get() [function.ftp-get]: Port command successful in /home/tridentb/public_html/meow/garrysmod/cache/dua/duaUpdate.php on line 26
Could not download ./b566575861.dua
Warning: ftp_get() [function.ftp-get]: Opening data channel for file transfer. in /home/tridentb/public_html/meow/garrysmod/cache/dua/duaUpdate.php on line 26
Could not download ./b570945014.dua
Warning: ftp_get() [function.ftp-get]: Port command successful in /home/tridentb/public_html/meow/garrysmod/cache/dua/duaUpdate.php on line 26
Could not download ./b599113784.dua
Warning: ftp_get() [function.ftp-get]: Opening data channel for file transfer. in /home/tridentb/public_html/meow/garrysmod/cache/dua/duaUpdate.php on line 26
Could not download ./b602223456.dua
Warning: ftp_get() [function.ftp-get]: Port command successful in /home/tridentb/public_html/meow/garrysmod/cache/dua/duaUpdate.php on line 26
Could not download ./b620185167.dua
Warning: ftp_get() [function.ftp-get]: Opening data channel for file transfer. in /home/tridentb/public_html/meow/garrysmod/cache/dua/duaUpdate.php on line 26
Could not download ./b640801866.dua
Warning: ftp_get() [function.ftp-get]: Port command successful in /home/tridentb/public_html/meow/garrysmod/cache/dua/duaUpdate.php on line 26
Any help is much appreciated!