Solved

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

Posted on 2008-10-14
1
710 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

930 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now