Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Output from ftp 'ls' to file?

Status
Not open for further replies.

croydon

Programmer
Apr 30, 2002
253
EU
I have a script that FTPs files to a remote server using the code below:

Set objShell = CreateObject("WSCRIPT.SHELL")
Set objFso = WScript.CreateObject("Scripting.FileSystemObject")
Set myFile=objFso.CreateTextFile("c:\ftprun.txt", True)

myFile.WriteLine "open " & strServer
myFile.WriteLine strLogin
myFile.WriteLine strPassword
myFile.WriteLine "put " & strLocalDir & strFileName1 & " " & strServerDir & strFileName1
myFile.WriteLine "put " & strLocalDir & strFileName2 & " " & strServerDir & strFileName2
myFile.WriteLine "put " & strLocalDir & strFileName3 & " " & strServerDir & strFileName3
myFile.WriteLine "bye"
myFile.Close

set oShell = CreateObject("WScript.shell")
oShell.run "ftp.exe -s:ftprun.txt", , True

In most cases this would be successful but to be sure I would like to connect again afterwards and run a directory listing to check the files have actually been received.

Is it possible to connect, run "ls" and have the output sent to a local file that can be subsequently read?

Any help would be appreciated.
 
Make another ftp script file that will do the ls then run it with a command like this:

oShell.run "ftp.exe -s:ftpLSrun.txt > LSOut.txt", , True

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Thanks. I also found that adding this line instead of "ls" will create the directory listing to a local file:

myFile.WriteLine "dir " & strServerDir & " c:\DirList.txt
 
Well if you can reach the folder to run a Dir command on it, why do you need to FTP in the first place??

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
EBGreen, Dir is a standard ftp command that croydon added to the ftp script file ...
 
Aah...brain hasn't fully engaged yet today...my mistake.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top