Currently I am working in Excel vba. I dont know much about it.
I am doing file transfer operation using putty sftp command, I am using below code for the same. I have also installed winscp & putty on my pc.
My code is:
Dim shell As Object
Dim command As String
Dim errorCode As Integer
Dim waitOnReturn As Boolean: waitOnReturn = True
Dim windowStyle As Integer: windowStyle = 0
Set shell = VBA.CreateObject("WScript.Shell")
command = "cmd.exe /c echo y |"C:\Program Files (x86)\PuTTY\pscp.exe"
-sftp -P 22 -l Username_Here -pw Password_Here
SRC_IP_Address_Here:File_Path_Here " " Destination_Path_Here
' error code is 0 if all ok otherwise 1
errorCode = shell.Run(command, windowStyle, waitOnReturn)
Above code works fine if ip address & destination path exists, but if ip address is not reachable in network excel takes 20-30 seconds for response & errorCode = 1.
Is it possible to modify above code in such a way that it should give me response only within 10 sec?
How can I set putty sftp connection timeout in above code?
I tried following links but not getting any result:
https://patrickmn.com/aside/how-to-keep-alive-ssh-sessions/
https://www.computerhope.com/unix/sftp.htm
https://library.netapp.com/ecmdocs/ECMP1196993/html/GUID-02FF883B-9913-4137-BC8B-5CB47282B944.html
https://tartarus.org/~simon/putty-snapshots/htmldoc/Chapter5.html