I am still very new to VBScript, and I need some help creating a log file that will show the output of an FTP. The reason that I need the log file is to later search through it for the string "Transfer complete". If I find it, then I know that the FTP worked. Below is a snip of my code. For some reason, the log file does not get written to. I also have a problem of the script continuing on before the FTP finishes. Is there a way to make the script wait until the FTP process is complete with out using the wait command?
The echoing of "found" and "not found" is only for troubleshooting purposes. If you need to see more of the code (ie.DIM), then just let me know. If you think that there is an easier way, I'm very open to making changes to the script.
Thanks in advance!
Scott
set objTextFile2 = fs.OpenTextFile("\\ntlifeprotest\workarea\cdpsxh\cmelog.txt",2,True)
Set wshshell = WScript.CreateObject("wscript.Shell")
retcode = Wshshell.run ("cmd /c ftp -s:cmeftp.scr "&strServer&" > objTextFile2",2,True)
'wscript.echo ("retcode = "&retcode)
objTextFile2.Close
'WScript.Sleep(100000) ' 10 second delay
Set objTextFile3 = fs.OpenTextFile("objTextFile2", 1)
Do Until objTextFile3.AtEndOfStream
strLine = objTextFile3.Readline
If InStr(strLine, "Transfer complete") <> 0 Then
wscript.echo strLine
wscript.echo "found"
else
wscript.echo strLine
wscript.echo "not found"
End If
Loop