tftp.vbs - vbscript script by ActiveXperts Software
tftp.vbs checks for file existence on a TFTP host.
Use tftp.vbs directly from ActiveXperts Network Monitor; in the Manager's 'Monitor' menu, select 'New Check (Script)' and select tftp.vbs. Configure the required parameter, or press 'Load a working sample'.
In ActiveXperts Network Monitor, Administrators can use three different scripting languages: Powershell, VBScript and SSH.
tftp.vbs script code
' /////////////////////////////////////////////////////////////////////////////// ' // ActiveXperts Network Monitor - VBScript based checks ' // For more information about ActiveXperts Network Monitor and VBScript, visit ' // http://www.activexperts.com/support/network-monitor/online/vbscript/ ' /////////////////////////////////////////////////////////////////////////////// Option Explicit ' Declaration of global variables Dim SYSDATA, SYSEXPLANATION ' SYSDATA is displayed in the 'Data' column in the Manager; SYSEXPLANATION in the 'LastResponse' column ' Constants - return values Const retvalUnknown = 1 ' ActiveXperts Network Monitor functions should always return True (-1, Success), False (0, Error) or retvalUnknown (1, Uncertain) ' // To test a function outside Network Monitor (e.g. using CSCRIPT from the ' // command line), remove the comment character (') in the following lines: ' Dim bResult ' bResult = CheckTftp( "srv202.activexperts-labs.com", "/network-monitor/readme.txt" ) ' WScript.Echo "Return value: [" & bResult & "]" ' WScript.Echo "SYSDATA: [" & SYSDATA & "]" ' WScript.Echo "SYSEXPLANATION: [" & SYSEXPLANATION & "]" Function CheckTftp( strHost, strFile ) ' Description: ' Check for file existence on a TFTP host ' This function uses ActiveXperts Network Component. ' ActiveXperts Network Component is automatically licensed when ActiveXperts Network Monitor is purchased ' For more information about ActiveXperts Network Component, see: www.activexperts.com/network-component ' Parameters: ' 1) strHost - Host name or IP address of the TFTP host ' 2) strFile - The file to check ' Usage: ' CheckTftp( "<Host>", "<File>" ) ' Sample: ' CheckTftp( "srv202.activexperts-labs.com", "/network-monitor/readme.txt" ) Dim objTftpServer, objFileSystem, strTempFile CheckTftp = retvalUnknown ' Default return value SYSDATA = "" ' Not used by this function SYSEXPLANATION = "" ' Set initial value Set objTftpServer = CreateObject("AxNetwork.TftpServer") ' Use binary transfer objTftpServer.BinaryTransfer = True ' Use default port 69 objTftpServer.HostPort = 69 ' Create a temp file to download file to Set objFileSystem = CreateObject("Scripting.FileSystemObject") strTempFile = objFileSystem.GetSpecialFolder(2) & "\" & objFileSystem.GetTempName ' Get file objTftpServer.Get strHost, strFile, strTempFile If( objTftpServer.LastError = 0 ) Then CheckTftp = True SYSEXPLANATION = "File [" & strFile & "] found on TFTP host [" & strHost & "]; size=[" & objTftpServer.BytesReceived & " bytes]" Else CheckTftp = False SYSEXPLANATION = "File [" & strFile & "] not found on TFTP host; result=[" & objTftpServer.LastError & ": " & objTftpServer.GetErrorDescription( objTftpServer.LastError ) & "]" End If If( objFileSystem.FileExists( strTempFile ) ) Then objFileSystem.DeleteFile strTempFile End If End Function