Board index » Visual Studio » Creating a LogFile in VBScript

Creating a LogFile in VBScript

Visual Studio134
I am creating a VBScript to automate a ftp process for uploading a

file. What I need to do is add the correct VBScript code to output a

logfile depending on the time and date the file was trasnfered and if

it was successful. Here is my current Script:

__________________________________________________________

Dim sFtpsite, sUsername, sPassword, sFromFolder, sFileName1

Set oShell = CreateObject("Wscript.Shell")





'FTP Upload to specified server

sFtpsite = "$$$$$$$$$$$$" ' FTP Site

sUserName = "$$$$$$$$$$$$" ' Location Specific User ID

sPassword = "$$$$$$$$$$$$" ' Location Specific User Password

sFromFolder = "$$$$$$$$$$$$" ' Folder where the file to be

uploaded is located

sFileName1 = "$$$$$$$$$$$$" ' File that is to be uploaded





' file to be created with instructions for ftp.exe

sFtpInp = "e:\temp\test\instructions.ftp" ' Specified file to be

created for FTP specific settings





With CreateObject("Scripting.FileSystemObject")

With .CreateTextfile(sFtpInp, True)

.WriteLine "open " & sFtpsite

.WriteLine "user " & sUsername

.WriteLine sPassword

.WriteLine "lcd " & sFromFolder

.WriteLine "put " & sFilename1

.WriteLine "Close"

.WriteLine "Quit"

.Close

End With

oShell.Run "%windir%\system32\ftp.exe -i -n -s:" & sFtpInp, 1,

True

' .DeleteFile sFtpInp

End With

____________________________________________________________



Thank you in advance for any reponses


-
 

Re:Creating a LogFile in VBScript

Any suggestions?



-

Re:Creating a LogFile in VBScript

?



-

Re:Creating a LogFile in VBScript

It's not entirely clear what you are having a problem with .......



You can create the log file with the same basic techniques you are

using to create

the ftp script file. You can get the date with the function date and

time with the

function time so you can enter them in the log file.



As for whether it was successful or not:



Does the command line you are using return that in standard output?



If so you can use oShell.Exec instead of oShell.Run. That way you can

read

the standard output returned by the command line by line and parse it

for

whether the transfer was successful or not.



If not I'm not certain how you would do it.



David E. Thomas



-

Re:Creating a LogFile in VBScript

JRS: In article <1142480993.997288.179300@u72g2000cwu.googlegroups.com>

, dated Wed, 15 Mar 2006 19:49:54 remote, seen in news:microsoft.public.

scripting.vbscript, dethomas143@charter.net posted :



Quote
You can get the date with the function date and

time with the

function time so you can enter them in the log file.



There is a risk of 24-hour error if that is done across midnight.



Instead, one should use a single call of Now.



--

© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©

Web <URL:www.merlyn.demon.co.uk/>">www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms

PAS EXE etc : <URL:www.merlyn.demon.co.uk/programs/>">www.merlyn.demon.co.uk/programs/> - see 00index.htm

Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.

-