FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Problem with readdir and ssh2
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Problem with readdir and ssh2 [message #180385] Thu, 07 February 2013 10:38 Go to previous message
Paolo Varalta is currently offline  Paolo Varalta
Messages: 3
Registered: February 2013
Karma:
Junior Member
Hi I'm Paolo from Italy.
I have a problem using readdir function (and other similar functions) under a ssh2 connection.
This is my script:

<?
$Server = "XXX.XXX.XXX.XXX";
$Porta = "XXXX";
$Login = "YYYYYYYY";
$Password = "ZZZZZZZZ";
if (!extension_loaded('ssh2'))
{exit();
}
$connection = ssh2_connect($Server, $Porta);
if (!$connection)
{exit();
}
if (!ssh2_auth_password($connection, $Login, $Password))
{exit();
}
if (!$sftp = ssh2_sftp($connection))
{exit();
}
if (is_dir("ssh2.sftp://$sftp/uploads/"))
{echo "1 Ok.\n";
$Directory = opendir("ssh2.sftp://$sftp/uploads/") or die ("");
if ($Directory)
{echo "2 Ok.\n";
while (false !== ($file = readdir($Directory)))
{echo "File -> ".$file."\n";
}
echo "3 Ok.\n";
}
}
unset($connection);
?>

(Obviously I have mask the important thinks)
If I try to use it in my VM debian server, I see this echo:

1 Ok
2 Ok
File -> TestFile1.csv
File -> TestFile2.csv
File -> TestFile3.csv
3 Ok

But if I try to use the same script in my regular server (a debian one, same version of the previous one, some php version, some ssh2 library version), I receive this echo:

1 Ok
2 Ok
3 Ok

Via tcpdump I see that SFTP server gives me exactly the same infos in both tests.
And if I try to open a file (knowing its name) with fopen/fgets in the second server, it works.

So why readdir (and functions similar) fails, while fopen/fgets works?
I watch php configurations on both server and thay seems identical.
Where do I have to search?

Thanks in advance
Best regards
Paolo
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: classes in PHP
Next Topic: anyone else writing Linux (or cross-system) applications in PHP?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 22:09:49 GMT 2024

Total time taken to generate the page: 0.05494 seconds