We help IT Professionals succeed at work.

Dir > Dir.txt       in FTP

Trutje
Trutje asked
on
Hello experts,

I am looking for the ftp command that writes a directory list to a text file. My fist guess was :

ftp > Dir >dir.txt

But it did not work.

Thanks,

Trutje
Comment
Watch Question

Commented:
Use the following or similar:

ftp ftp.site.com > dir.txt
<name>
<password>
cd <dir>
dir
bye

You really need to know your way around the site because you won't be able to see the output. Your commands will still be echoed to the screen. When you are done, dir.txt will contain everything the ftp server sent. Edit as required.

Mike

Commented:

Mike was almost right but this works a bit better.
Create a script and save it as an ascii file (do not forget the BYE at the end or you will have a long wait ahead of you..):

open ftp.site.com
username
password
cd directory/directory2/directory3
dir
bye


Then start following (or write a .bat / .cmd file for it):
  ftp -s:scriptname >outputfile.txt 2>outputerrors.txt

The result, including all other output of the ftp-session will be stored in the "outputfile.txt" file. Alle errors in the commandline, ftp-program itself (everything BUT the session-errors) will be stored in the "outputerrors.txt" file.

Regards,
Eric


Author

Commented:
Thanks thats the aswer I was looking for