![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
![]() |
| 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 | |||