Patrick
2004-01-21 15:49:51 UTC
I know I could use FTP from VBScript using something like the following.
However, is there a better way to do this so it's a little more
"interactive" (i.e., allow the script to interpret intelligently the
response from the server after issuing each command before continuing. e.g.
iff cannot open connection to servername, then it might be worth waiting a
while and then retrying instead of sending a username).
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("WScript.Shell")
sFtpCmds = "c:\ftp.inp"
Set fFtpCmds = oFSO.CreateTextFile(sFtpCmds, _
OverwriteIfExist, OpenAsASCII)
' server to open
fFtpCmds.WriteLine "open servername"
' username
fFtpCmds.WriteLine "username"
' password
fFtpCmds.WriteLine "password"
fFtpCmds.WriteLine "GET testfile.txt"
fFtpCmds.WriteLine "quit"
fFtpCmds.Close
sCmd = "ftp -i -s:" & sFtpCmds
oShell.Run sCmd, 0
However, is there a better way to do this so it's a little more
"interactive" (i.e., allow the script to interpret intelligently the
response from the server after issuing each command before continuing. e.g.
iff cannot open connection to servername, then it might be worth waiting a
while and then retrying instead of sending a username).
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("WScript.Shell")
sFtpCmds = "c:\ftp.inp"
Set fFtpCmds = oFSO.CreateTextFile(sFtpCmds, _
OverwriteIfExist, OpenAsASCII)
' server to open
fFtpCmds.WriteLine "open servername"
' username
fFtpCmds.WriteLine "username"
' password
fFtpCmds.WriteLine "password"
fFtpCmds.WriteLine "GET testfile.txt"
fFtpCmds.WriteLine "quit"
fFtpCmds.Close
sCmd = "ftp -i -s:" & sFtpCmds
oShell.Run sCmd, 0