Hi Everyone
My objective is to download, a file from an sftp server, and I am trying to adapt the code from another question on this site to do so (I pasted the code below for your convinience).
I downloaded psftp from putty. psftp closes when I try to connect manually using the following command line: open usernameassword@server.com.port:1111
I have three questions (for now):
1. Is something wrong with my command line. if not then what could be the problem.
2. As far as I know SFTP would normally utilize get/put commands, but i dont see a put command in the code below, so I dont understand where i should enter the get command to download hte file instead of uploading it (which is what the code below is supposed to be doing).
3. is it correct that pRemotePath is the location of hte file on the sftp server, and pFile is the location I want the file downloaded to
I am not a super user (obviously...) so a simple explanation would be very much appreciated. If you have a better aproach feel free to share too.
Thank you kindly
Ron
Public Sub SftpGet()
Const cstrSftp As String = """C:\Users\Ron\UtilityTools\psftp.exe"""
Dim strCommand As String
Dim pUser As String
Dim pPass As String
Dim pHost As String
Dim pFile As String
Dim pRemotePath As String
pUser = "uid"
pPass = "PW"
pHost = "dns"
pFile = "C:\Users\Ron\activity.txt"
pRemotePath = "Z:/activity.log"
strCommand = cstrSftp & " -sftp -l " & pUser & " -pw " & pPass & _
" " & pFile & " " & pHost & ":" & pRemotePath
Debug.Print strCommand
Shell strCommand, 1 ' vbNormalFocus '
End Sub
My objective is to download, a file from an sftp server, and I am trying to adapt the code from another question on this site to do so (I pasted the code below for your convinience).
I downloaded psftp from putty. psftp closes when I try to connect manually using the following command line: open usernameassword@server.com.port:1111
I have three questions (for now):
1. Is something wrong with my command line. if not then what could be the problem.
2. As far as I know SFTP would normally utilize get/put commands, but i dont see a put command in the code below, so I dont understand where i should enter the get command to download hte file instead of uploading it (which is what the code below is supposed to be doing).
3. is it correct that pRemotePath is the location of hte file on the sftp server, and pFile is the location I want the file downloaded to
I am not a super user (obviously...) so a simple explanation would be very much appreciated. If you have a better aproach feel free to share too.
Thank you kindly
Ron
Public Sub SftpGet()
Const cstrSftp As String = """C:\Users\Ron\UtilityTools\psftp.exe"""
Dim strCommand As String
Dim pUser As String
Dim pPass As String
Dim pHost As String
Dim pFile As String
Dim pRemotePath As String
pUser = "uid"
pPass = "PW"
pHost = "dns"
pFile = "C:\Users\Ron\activity.txt"
pRemotePath = "Z:/activity.log"
strCommand = cstrSftp & " -sftp -l " & pUser & " -pw " & pPass & _
" " & pFile & " " & pHost & ":" & pRemotePath
Debug.Print strCommand
Shell strCommand, 1 ' vbNormalFocus '
End Sub