Solved

Trying to get a directory list from Secure FTP into a text file

Posted on 2008-10-14
1
716 Views
Last Modified: 2013-12-13
Hello,

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!
0
Comment
Question by:flashjordan
1 Comment
 
LVL 4

Accepted Solution

by:
webopius earned 500 total points
ID: 22715541
Hi,

You can try this using your ftp client:

ls [remote-directory] [local-file]

For example, "ls . listing" will create a LOCAL file called "listing" containing all the files in the current ftp directory.

Many windows and unix ftp connections support this syntax.
Hope it works for you!
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Outsource Your Fax Infrastructure to the Cloud (And come out looking like an IT Hero!) Relative to the many demands on today’s IT teams, spending capital, time and resources to maintain physical fax servers and infrastructure is not a high priority.
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question