|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2001-01-23 22:23 UTC] steve at szabos dot com
The ftp_nlist and ftp_rawlist functions failed to work for me. I am using PHP.EXE v4.0.4 from a Windows 2000 machine connecting to a Free BSD box running the following FTP server:
Our.ftp.server FTP server (Version wu-2.6.1(1) Mon Jul 3 03:07:01 EDT 2000)
Both ftp_nlist and ftp_rawlist return a single blank string ("") into the result array.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 07:00:01 2025 UTC |
Thanks for responding. I no longer have access to the FreeBSD FTP server that I was connecting to, so it is no longer an issue (for me). My script is attached below. If you do see an issue with the code, I am still interested in your response. <? $bDebug = 1; $aDomain = array ( "xyz.com", "z" ); if ($bDebug) echo "Number in array =" . count ($aDomain) . "<BR>"; for ( $i=0; $i < count ($aDomain) ; ) { if ( $bDebug ) echo "Openning \"" . $aDomain[$i] . "\"...<BR>"; $nFTP = ftp_connect ( $aDomain[$i] ); if ( $nFTP == 0 ) { echo "Failed to open $aDomain[$i]. Aborting...<BR>"; exit(); } $nResult = ftp_login ( $nFTP, $aDomain[$i+1], "password" ); if ( $nResult == 0 ) { echo "Failed to login to $aDomain[$i]. Aborting...<BR>"; exit(); } else echo "Login to $aDomain[$i] succeeded.<BR>"; if ( $bDebug) echo "<BR>ftp_pwd=" . ftp_pwd ( $nFTP ) . "<BR>". $nResult = ftp_chdir ( $nFTP, "logs"); if ( $nResult == 0) { echo "ftp_chdir failed. Aborting...<BR>"; exit(); } if ( $bDebug) echo "<BR>ftp_pwd=" . ftp_pwd ( $nFTP ) . "<BR>". $aFiles = Array( "Oct100.log.gz", "Nov100.log.gz", "Dec100.log.gz", "mtd.log"); // $aFiles = ftp_rawlist ( $nFTP, "/mnt/web/guide/accumeddata/logs/*.gz"); // echo "rawlist = " . count ( $aFileList ) . "<BR>"; // $aFiles = ftp_nlist ( $nFTP, "*.gz"); if ( $bDebug ) { echo "count(aFiles)=" . count ($aFiles ) . "<BR>"; for ( $j=0; $j <= count($aFiles); $j++ ) echo "$j=\"$aFiles[$j]\"<BR>"; } // Get all the Monthly archives (*.GZ) for ( $j=0; $j < count($aFiles); $j++ ) { $sLocalFile = $aDomain[$i] . "-" . $aFiles[$j]; $sLocalFile = str_replace ( "/", "-", $sLocalFile ); $sRemoteFile = $aFiles[$j]; if ( $bDebug) { echo "sLocalFile=\"$sLocalFile\"<BR>"; echo "sRemoteFile=\"$sRemoteFile\"<BR>"; } $nResult = ftp_get ( $nFTP, $sLocalFile, $sRemoteFile, FTP_BINARY ); if ( $nResult == 0) { echo "ftp_get failed. Aborting..."; exit(); } } // Get the current month also. $nResult = ftp_get ( $nFTP, $sLocalFile, "mtd.log", FTP_BINARY ); if ( $nResult == 0) { echo "ftp_get of mtd.log failed. Aborting..."; exit(); } $nResult = ftp_quit ( $nFTP ); if ( $nResult == 0 ) { echo "ftp_quit failed. Aborting..."; exit(); } $i = $i + 2; } ?>I must be blind. :) The ftp server information was in the first comment of yours: wu-2.6.1 I installed this same ftp server to my machine and tried with this script: <?php $conn_id = ftp_connect("localhost"); $login_result = ftp_login($conn_id, "username", "pass"); $rawlist = ftp_rawlist($conn_id,"*.gz"); $nlist = ftp_nlist($conn_id,"*.gz"); ftp_quit($conn_id); print_r($rawlist); print_r($nlist); ?> And this worked just fine. So closed. Reopen if you can reproduce this some time. --Jani