Bug #8874 Updated: ftp_nlist and rawlist not working
| From: | sniper@php.net | Date: | Thu, 16 Aug 2001 22:37:20 +0000 |
| Subject: | Bug #8874 Updated: ftp_nlist and rawlist not working | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-63478@lists.php.net to get a copy of this message | ||
ID: 8874
Updated by: sniper
Reported By: steve@szabos.com
Old Status: Open
Status: Closed
Bug Type: FTP related
Operating System: Windows 2000 Advanced Server
PHP Version: 4.0.4
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[2001-08-16 00:26:06] steve@szabos.com
Per my previous message, I no longer have access to the FreeBSD server to try it.
------------------------------------------------------------------------
[2001-08-15 02:07:31] sniper@php.net
This bug report was for PHP 4.0.4. There have been a few
changes since that in PHP 4.0.6. Have you tried with it?
And also, these functions do work on most ftp servers. What was the version of the ftp server on
which this didn't work?
--Jani
------------------------------------------------------------------------
[2001-08-14 21:07:00] steve@szabos.com
$aFiles = Array( "Oct100.log.gz", "Nov100.log.gz");
// $aFiles = ftp_rawlist (nFTP, "/mnt/web/guide/accumeddata/logs/*.gz");
$aFiles = ftp_nlist ( $nFTP, "*.gz");
echo "count(aFiles)=" . count ($aFiles ) . "<BR>";
------------------------------------------------------------------------
[2001-08-14 20:10:30] jmoore@php.net
can you provide a smaller script that produces the bug please. preferably less than ten lines of
code which requires nothing other than the bare min.. IE no extenal files etc.
------------------------------------------------------------------------
[2001-07-22 00:23:57] steve@szabos.com
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;
}
?>
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/?id=8874
Edit this bug report at http://bugs.php.net/?id=8874&edit=1