View Single Post
  #7  
Old 01-04-2018, 05:14 PM
bstedh bstedh is offline
Registered User
 
Join Date: Jan 2018
Posts: 41
Ok, I wrote my function.

I still have to write the function that creates the file before I can test it. But its time to go cook dinner. "Tomorrow is another day"

The only thing I really changed was to switch to waitforstring instead of get. Not sure if that will be an issue.

Code:
Function BSMsftpGET(FileName,Destination)
	Set objSFTPTab = crt.GetScriptTab.ConnectSFTP
	strScreenText = _
	objSFTPTab.Screen.WaitforString("sftp>",5)
	If strScreenText = 0 Then
		BSMsftpGET = "TimeOut"
		objSFTPTab.Close
		Exit Function
	End If
	objSFTPTab.Screen.Send "ls -l" & vbcr
	strFileListing = objSFTPTab.Screen.ReadString("sftp>")
	If InStr(strFileListing,FileName) Then 
		BSMsftpGET = "NoFile"
		objSFTPTab.Close
		Exit Function
	End If
	objSFTPTab.Screen.Send "lcd " & Destination & vbcr
	objSFTPTab.Screen.WaitForString "sftp>"
	objSFTPTab.Screen.Send "get " & FileName & vbcr
	strResults = objSFTPTab.Screen.ReadString("sftp>")
	If Instr(strResults, "100%") > 0 Then
		BSMsftpGET = "Success"
	Else
		BSMsftpGET = "Fail"
	End If
	objSFTPTab.Close
End Function
Reply With Quote