Trying to get a directory list from Secure FTP into a text file
Posted on 2008-10-14
I need to run some queries on a list of filenames in a remote SFTP account. I'm not running the queries in FTP, I just need the list of filenames, then I'll run the parse them using PHP.
I've tried the following:
1) Connect to the SFTP account using PHP. I have OpenSSL installed. I've tried to connect using ftp_connect and ftp_ssl_connect, and on ports 21 and 22. The connection always fails. However, it connects fine using an FTP client on my computer (I use Secure File Transfer Client, FileZilla Client and PuttyFTP). The remote FTP server requires the connecton to be Secure FTP.
2) My 2nd option was to connect using an FTP client from my computer, then just copy the list of filenames into a text file, and then simply get my PHP script to read the text file rather than connecting to the FTP itself. However I can't get this to work either because I can't find an FTP client that will allow me to copy the full list of filenames (the list is very long). I can't even find a command line ftp with a copy function for this.
Please can you explain to me how to get the SFTP in PHP working, or let me know of an FTP client which will allow me to copy the directory listing to a text file.
Please help! Thanks!