Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #8319 > unrolled thread
| Started by | Paolo Varalta <varaltapaolo@gmail.com> |
|---|---|
| First post | 2013-02-07 02:38 -0800 |
| Last post | 2013-02-07 11:24 -0500 |
| Articles | 6 — 2 participants |
Back to article view | Back to comp.lang.php
Problem with readdir and ssh2 Paolo Varalta <varaltapaolo@gmail.com> - 2013-02-07 02:38 -0800
Re: Problem with readdir and ssh2 Jerry Stuckle <jstucklex@attglobal.net> - 2013-02-07 08:58 -0500
Re: Problem with readdir and ssh2 Paolo Varalta <varaltapaolo@gmail.com> - 2013-02-07 06:28 -0800
Re: Problem with readdir and ssh2 Jerry Stuckle <jstucklex@attglobal.net> - 2013-02-07 09:54 -0500
Re: Problem with readdir and ssh2 Paolo Varalta <varaltapaolo@gmail.com> - 2013-02-07 07:31 -0800
Re: Problem with readdir and ssh2 Jerry Stuckle <jstucklex@attglobal.net> - 2013-02-07 11:24 -0500
| From | Paolo Varalta <varaltapaolo@gmail.com> |
|---|---|
| Date | 2013-02-07 02:38 -0800 |
| Subject | Problem with readdir and ssh2 |
| Message-ID | <2207dc5f-9d96-4ef7-b1bd-388426f6ddb1@googlegroups.com> |
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
[toc] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2013-02-07 08:58 -0500 |
| Message-ID | <kf0btq$nr2$1@dont-email.me> |
| In reply to | #8319 |
On 2/7/2013 5:38 AM, Paolo Varalta wrote:
> 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
>
How is system security set up in the working and failing systems?
Perhaps you don't have permission to list the directory in the failing one?
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[toc] | [prev] | [next] | [standalone]
| From | Paolo Varalta <varaltapaolo@gmail.com> |
|---|---|
| Date | 2013-02-07 06:28 -0800 |
| Message-ID | <1a908c20-f48b-4b41-af86-279e4f363d1b@googlegroups.com> |
| In reply to | #8325 |
Il giorno giovedì 7 febbraio 2013 14:58:44 UTC+1, Jerry Stuckle ha scritto:
> On 2/7/2013 5:38 AM, Paolo Varalta wrote:
>
> > 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
>
> >
>
>
>
> How is system security set up in the working and failing systems?
>
> Perhaps you don't have permission to list the directory in the failing one?
>
>
>
> --
>
> ==================
>
> Remove the "x" from my email address
>
> Jerry Stuckle
>
> JDS Computer Training Corp.
>
> jstucklex@attglobal.net
>
> ==================
Hi Jerry and thank you.
How/Where can I find the infos of that kind of permissions?
Thanks in advance
Best regards
Paolo
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2013-02-07 09:54 -0500 |
| Message-ID | <kf0f63$b16$1@dont-email.me> |
| In reply to | #8327 |
On 2/7/2013 9:28 AM, Paolo Varalta wrote:
> Il giorno giovedì 7 febbraio 2013 14:58:44 UTC+1, Jerry Stuckle ha scritto:
>> On 2/7/2013 5:38 AM, Paolo Varalta wrote:
>>
>>> 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
>>
>>>
>>
>>
>>
>> How is system security set up in the working and failing systems?
>>
>> Perhaps you don't have permission to list the directory in the failing one?
>>
>>
>>
>
> Hi Jerry and thank you.
>
> How/Where can I find the infos of that kind of permissions?
>
> Thanks in advance
> Best regards
> Paolo
>
It all depends on the version of Linux you're using. Try a Linux
administration book (or newsgroup) for your version.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[toc] | [prev] | [next] | [standalone]
| From | Paolo Varalta <varaltapaolo@gmail.com> |
|---|---|
| Date | 2013-02-07 07:31 -0800 |
| Message-ID | <09155195-00c4-4ce2-a2a0-c4dac0b883cc@googlegroups.com> |
| In reply to | #8328 |
Il giorno giovedì 7 febbraio 2013 15:54:22 UTC+1, Jerry Stuckle ha scritto:
> On 2/7/2013 9:28 AM, Paolo Varalta wrote:
>
> > Il giorno gioved� 7 febbraio 2013 14:58:44 UTC+1, Jerry Stuckle ha scritto:
>
> >> On 2/7/2013 5:38 AM, Paolo Varalta wrote:
>
> >>
>
> >>> 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
>
> >>
>
> >>>
>
> >>
>
> >>
>
> >>
>
> >> How is system security set up in the working and failing systems?
>
> >>
>
> >> Perhaps you don't have permission to list the directory in the failing one?
>
> >>
>
> >>
>
> >>
>
> >
>
> > Hi Jerry and thank you.
>
> >
>
> > How/Where can I find the infos of that kind of permissions?
>
> >
>
> > Thanks in advance
>
> > Best regards
>
> > Paolo
>
> >
>
>
>
> It all depends on the version of Linux you're using. Try a Linux
>
> administration book (or newsgroup) for your version.
>
>
>
> --
>
> ==================
>
> Remove the "x" from my email address
>
> Jerry Stuckle
>
> JDS Computer Training Corp.
>
> jstucklex@attglobal.net
>
> ==================
Hi.
Can you help me, telling me which kind of permission (or its name) I have to look for in a server using debian 6.0?
Thanks in advance
Best regards
Paolo
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2013-02-07 11:24 -0500 |
| Message-ID | <kf0kfs$amr$1@dont-email.me> |
| In reply to | #8329 |
On 2/7/2013 10:31 AM, Paolo Varalta wrote:
> Il giorno giovedì 7 febbraio 2013 15:54:22 UTC+1, Jerry Stuckle ha scritto:
>> On 2/7/2013 9:28 AM, Paolo Varalta wrote:
>>
>>> Il giorno gioved� 7 febbraio 2013 14:58:44 UTC+1, Jerry Stuckle ha scritto:
>>
>>>> On 2/7/2013 5:38 AM, Paolo Varalta wrote:
>>
>>>>
>>
>>>>> 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
>>
>>>>
>>
>>>>>
>>
>>>>
>>
>>>>
>>
>>>>
>>
>>>> How is system security set up in the working and failing systems?
>>
>>>>
>>
>>>> Perhaps you don't have permission to list the directory in the failing one?
>>
>>>>
>>
>>>>
>>
>>>>
>>
>>>
>>
>>> Hi Jerry and thank you.
>>
>>>
>>
>>> How/Where can I find the infos of that kind of permissions?
>>
>>>
>>
>>> Thanks in advance
>>
>>> Best regards
>>
>>> Paolo
>>
>>>
>>
>>
>>
>> It all depends on the version of Linux you're using. Try a Linux
>>
>> administration book (or newsgroup) for your version.
>>
>>
>>
>> --
>>
>> ==================
>>
>> Remove the "x" from my email address
>>
>> Jerry Stuckle
>>
>> JDS Computer Training Corp.
>>
>> jstucklex@attglobal.net
>>
>> ==================
>
> Hi.
>
> Can you help me, telling me which kind of permission (or its name) I have to look for in a server using debian 6.0?
>
> Thanks in advance
> Best regards
> Paolo
>
As I said - you need to be asking in a newsgroup for Linux, preferably
Debian or Ubuntu. Debian does have an excellent email list for user
assistance.
Ask in the right place and you'll get good answers.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web