# $language = "VBScript" # $interface = "1.0" ' Example script that starts SecureNetTerm, connects to the active profile, ' then waits for a $ prompt. When it is received, it tests the SFTP commands. ' This assumes an SSH style connection in which no userid or password is ' required to be entered on the command line. ' You should place a very large (4-8MB) file in the host /tmp directory, ' with a name of remote.fil which will be used by this test. ' Globals dim dir dim snt Sub StartSNT ' Request to handle errors ourselves so we can handle possible failure ' of GetObject() to connect to SecureNetTerm... ' On Error Resume Next ' Gets an instance of SecureNetTerm if it is already running Set snt = GetObject(,"SecureNetTerm.Document") If TypeName(snt) <> "Document" Then ' It wasn't already running so start it running. Set snt = CreateObject("SecureNetTerm.Document") End If End Sub Sub Main() StartSNT() snt.WindowState = 1 'Normal (SW_SHOW) If snt.Connected <> TRUE Then If snt.Connect("Active") <> TRUE Then Exit Sub End If If snt.WaitForString("$",15) <> TRUE Then Exit Sub End If End If ret = snt.SFTP_OpenConnection() if ret = TRUE Then dir = snt.SFTP_GetCurrentDirectory() snt.StatusLine "SFTP Directory = " + dir ret = snt.SFTP_SetCurrentDirectory("/tmp") if ret = TRUE Then ' Make sure test directory/files are not present snt.SFTP_DeleteFile("sntData/remote2.fil") snt.SFTP_RemoveDirectory("sntData") ret = snt.SFTP_GetFile("remote.fil","local.fil") if ret = TRUE Then dir = snt.SFTP_GetCurrentDirectory() snt.StatusLine "SFTP Directory = " + dir ret = snt.SFTP_CreateDirectory("sntData") if ret = TRUE Then ret = snt.SFTP_PutFile("local.fil","sntData/remote1.fil") if ret = TRUE Then ret = snt.SFTP_RenameFile("sntData/remote1.fil","sntData/remote2.fil") if ret = TRUE Then ret = snt.SFTP_ChMod("sntData/remote2.fil","644") if ret = TRUE Then ret = snt.SFTP_GetFile("sntData/remote2.fil","local2.fil") if ret = TRUE Then ret = snt.SFTP_DeleteFile("sntData/remote2.fil") if ret = TRUE Then ret = snt.SFTP_RemoveDirectory("sntData") End If End If End If End If End If End If End If End If snt.SFTP_CloseConnection() snt.StatusLine "" End If End Sub