How to redirect the output of a FTP recursive listing to a local file with Windows 7 FTP client?
When using the DOS command FTP in Windows 7, I can use this FTP command to list recursively all files of the remote directory:
ftp> ls -R
I cannot get the output of ls -R to a local file, FTP keeps complaining about the syntax:
ftp> ls -R . save.txt
usage: ls remote-directory local-file
Can someone explain why, and how to get the result I wanted?
as far as i know once you are in the interactive ftp shell the output can't be captured.
but you can either pipe commands to the ftp command or specify a file with the commands (required if you need multiple commands, like specifying username/password)
then you redirect the std out to a file.
like this:
echo ls -R | ftp yourHostname > save.txt
or you place all your commands (lets say mycommands.txt) in a text file and call it with
ftp -s:mycommands.txt > save.txt
mycommmands.txt could look like this
user yourName yourPassword
open yourHostname
cd someDirectory
ls -R
(i couldn't test the second example right now, so let me know if it doesn't work)
Assuming you are using simple ftp via command line, Use dir command with -Rl option to search recursively and copy it to a file and then search the file using grep, find or whatever way is supported on your OS.
ftp> dir -Rl education.txt
output to local-file: education.txt? y
227 Entering Passive Mode (9,62,119,15,138,239)
150 Opening ASCII mode data connection for file list
226 Transfer complete
ftp> dir * Sample.txt
This worked for me.