0

I'm trying to feed a ftp_raw() command's output to a file. More specifically, the command is ftp_raw( $ftpConn, 'LIST -al' ); and I want to write the filelist to a file, or at least show it to the console screen...

I mean, I'm doing a var_dump( ftp_raw( $ftpConn, 'LIST -al' ) ); and I'm correctly getting a response like this:

array(1) {
  [0]=>
  string(42) "150 Opening data connection for file list."
}

but I also want to get the filelist itself somehow.

Can you please help me with this?

Faye D.
  • 833
  • 1
  • 3
  • 16
  • 1
    The file list isn't sent as a response, it's sent over the data connection, just like when you download a file. – Barmar Apr 09 '23 at 04:02
  • So it should be output to the console anyway? Are you sure about that? Cause I'm not getting anything – Faye D. Apr 09 '23 at 04:04
  • Why do you think that? The data connection is a new connection opened for each file transfer. – Barmar Apr 09 '23 at 04:05
  • You need to study how the FTP protocol works. Or just use a higher-level interface instead of raw commands. – Barmar Apr 09 '23 at 04:05
  • I tried `ftp_nlist()` but there is a problem I'm facing and tried to use a LIST instead... – Faye D. Apr 09 '23 at 04:09
  • You can take a look at my initial question here https://stackoverflow.com/questions/75968142/ftp-ssl-connect-and-ftp-nlist – Faye D. Apr 09 '23 at 04:09
  • [side-note]: if you use phpseclib PHP class, you may use something like `$sftp->nlist()` – Ken Lee Apr 09 '23 at 04:36

0 Answers0