Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - FTP return code

Reply
 
Old 08-18-2008   #1 (permalink)
Leon


 
 

FTP return code

Hi all

I'm logging to a ftp server for downloading files.
If the connection is down I want to have a line in logfile telling
that the server could not be reached.
How do I do that?
Thanks

My System SpecsSystem Spec
Old 08-18-2008   #2 (permalink)
McKirahan


 
 

Re: FTP return code

"Leon" <kim.zethsen@xxxxxx> wrote in message
news:e0a129f4-b6be-4521-a762-ca746caabc8d@xxxxxx
Quote:

> Hi all
>
> I'm logging to a ftp server for downloading files.
> If the connection is down I want to have a line in logfile telling
> that the server could not be reached.
> How do I do that?

Are you "logging to a ftp" via script? How is your "logfile" created?


I do the following:
1) create a text file with ftp commands;
2) execute ftp with the "-s:" option and
pipe the output to a log file;
3) use fso to "readall" the log file then
use InStr() to test for "Not connected."


Will this help? Watch for word-wrap.

Save as "FTP_test.vbs"; modify the value of "cCMD" as needed.


Option Explicit
'****
'* Test ftp success by examining the log file it creates.
'****
'*
'* Declare Constants
'*
Const cVBS = "FTP_test.vbs"
Const cFTP = "FTP_test.ftp"
Const cLOG = "FTP_test.log"
Const cCMD = "open {domain}|{userid}|{passwd}|dir|close|bye"
Const cWSS = "%comspec% /C ftp -i -s:"
'*
'* Declare Variables
'*
Dim strCMD
strCMD = Replace(cCMD,"|",vbCrLf)
Dim strDIR
strDIR = CreateObject("WScript.Shell").CurrentDirectory & "\"
Dim strFTP
strFTP = strDIR & cFTP
Dim strLOG
strLOG = strDIR & cLOG
Dim strOTF
Dim strWSS
If InStr(strFTP," ") = 0 Then
strWSS = cWSS & strFTP
Else
strWSS = cWSS & Chr(34) & strFTP & Chr(34)
End If
If InStr(strLOG," ") = 0 Then
strWSS = strWSS & " >> " & strLOG
Else
strWSS = strWSS & " >> " & Chr(34) & strLOG & Chr(34)
End If
WScript.Echo strWSS
'*
'* Declare Objects
'*
Dim objCTF
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objOTF
Dim objWSS
'*
'* Create ".ftp"
'*
Set objCTF = objFSO.CreateTextFile(strFTP,True)
objCTF.WriteLine(strCMD)
Set objCTF = Nothing
'*
'* Invoke ".ftp"
'*
Set objWSS = CreateObject("WScript.Shell")
objWSS.Run strWSS,2,True
Set objWSS = Nothing
'*
'* Delete ".ftp"
'*
If objFSO.FileExists(strFTP) Then objFSO.DeleteFile(strFTP)
'*
'* Review ".log"
'*
Set objOTF = objFSO.OpenTextFile(strLOG,1)
strOTF = objOTF.ReadAll
Set objOTF = Nothing
'*
'* Report Status
'*
Set objFSO = Nothing
If InStr(strOTF,"Not connected.") > 0 Then
MsgBox "Not connected.",vbCritical,cVBS
Else
MsgBox "Connected.",vbInformation,cVBS
End If


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Windows Update for Vista KB946041 return error code 800736B2 Vista installation & setup
Return code VB Script
Live Messenger ignore Win32 API ReadFile return code and 100% CPU Live Messenger
COM+ Event System detected a bad return code Vista General
ATI Radeon Drivers - Code 43, Code 37 & Code 10 Vista hardware & devices


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46