php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #58710 Missing Function: ssh2_ sftp_ ls
Submitted: 2009-06-02 18:47 UTC Modified: 2017-10-24 06:49 UTC
Votes:6
Avg. Score:4.8 ± 0.4
Reproduced:6 of 6 (100.0%)
Same Version:5 (83.3%)
Same OS:5 (83.3%)
From: tjg at soe dot ucsc dot edu Assigned:
Status: Open Package: ssh2 (PECL)
PHP Version: 5.1.6 OS: CentOS 5.3
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: tjg at soe dot ucsc dot edu
New email:
PHP Version: OS:

 

 [2009-06-02 18:47 UTC] tjg at soe dot ucsc dot edu
Description:
------------
It would be really nice to have a function called:

ssh2_sftp_ls($handle, $folder)

It is currently not possible (without hacks) to list the files in a given directory on a remote sftp server with the ssh2 library.

If possible (or as a replacement) it would also be nice to have:

ssh2_sftp_glob($handle, $pattern)

Both of these should return an array of file names.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-06-15 20:40 UTC] langemeijer@php.net
This can be done. Please consider this solution:

$connection = ssh2_connect('localhost', 22);
ssh2_auth_agent($connection, 'user');
$sftp = ssh2_sftp($connection);

$folder = opendir("ssh2.sftp://$sftp/path/to/dir");

while (($file_name = readdir($folder)) !== false) {
  echo $file_name . "\n";
}
 [2012-06-15 20:41 UTC] langemeijer@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: langemeijer
 [2012-06-15 21:22 UTC] langemeijer@php.net
Solution wont work as ssh2_auth_agent() is not available in last release. use any 
other ssh2_auth_() function instead.
 [2012-06-18 15:35 UTC] tjg at soe dot ucsc dot edu
Actually, using the URL wrappers isn't a great solution for this, as many shared hosting providers have that feature disabled because it presents a bit of a security problem.
 [2012-06-18 19:32 UTC] langemeijer@php.net
-Status: Closed +Status: Re-Opened
 [2017-10-24 05:22 UTC] kalle@php.net
-Status: Re-Opened +Status: Assigned
 [2017-10-24 06:49 UTC] kalle@php.net
-Status: Assigned +Status: Open -Assigned To: langemeijer +Assigned To:
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 05:01:29 2024 UTC