Computing.Net > Forums > Programming > VBScript help creating a log file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

VBScript help creating a log file

Reply to Message Icon

Name: humerick
Date: June 9, 2006 at 10:57:41 Pacific
OS: WinXP
CPU/Ram: Intel
Product: Dell
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: Michael J (by mjdamato)
Date: June 9, 2006 at 13:07:38 Pacific
Reply:

Here's how I create and write to a log file:

Set objFSO = CreateObject("scripting.filesystemobject")
Set logStream = objFSO.createtextfile(logFile , True)
logStream.writeline "Text written into log file"
logStream.Close

You probably can use an echo, but your echos are not specifying "where" to echo to, so it makes sense there is nothing in your log files.

As for pausing execution of the script until the FTP process completes, the third parameter in the Wshshell.run command should pause the script until the Run command completes if it is set to true. Yours is set to true, so I don't know why it is not working.

Michael J


0

Response Number 2
Name: humerick
Date: June 9, 2006 at 13:18:04 Pacific
Reply:

I somewhat understand what you are doing Michael, but how do I make the output from the FTP write to that file?


0

Response Number 3
Name: Michael J (by mjdamato)
Date: June 9, 2006 at 22:50:54 Pacific
Reply:

Don't know.

Michael J


0

Response Number 4
Name: Mechanix2Go
Date: June 11, 2006 at 00:02:28 Pacific
Reply:

I don't know VB but if I have a BAT, mybat, which does:

ftp -s:script

I can make a log with:

mybat > log


If at first you don't succeed, you're about average.

M2


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: VBScript help creating a log file

Help creating a Batch file urgent www.computing.net/answers/programming/help-creating-a-batch-file-urgent/15963.html

Help ... READ a log file... www.computing.net/answers/programming/help-read-a-log-file/16493.html

Help creating a batch file www.computing.net/answers/programming/help-creating-a-batch-file/13059.html