downloading file with SFTP

ronstar

Registered User.
Local time
Today, 02:04
Joined
Sep 1, 2011
Messages
23
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 username:password@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
 
I normally don't see "port" in the command line. Have you tried this ?

username:password@server.com:1111

Does this FTP client have a scripting utility? In the past (WS_FTP). I created scripts on the fly, saved them to to a file and ran by calling the client with the script command in the command line arguments. Worked a treat for my needs.
 
I normally don't see "port" in the command line. Have you tried this ?

username:password@server.com:1111

Does this FTP client have a scripting utility? In the past (WS_FTP). I created scripts on the fly, saved them to to a file and ran by calling the client with the script command in the command line arguments. Worked a treat for my needs.

Hi I cant see the difference between the line you posted and the one i did because they are editing the string.

what I ported was username(colon)pw@server.com/port:1222

not sure about hte scripting. I cant find anything in the documentation (http://the.earth.li/~sgtatham/putty/0.62/htmldoc/Chapter6.html#psftp-commands)

Thanks
Ron
 
connecting to API on server

Hi,

I would like to expand my program so that it can connect to an API of a tool on an external server. The connection to the API is done with Server IP, UID, PW.

I was wondering if anyone could direct me on my way to establishing such a connection and make calls with VBA.

Thanks
Ron
 

Users who are viewing this thread

Back
Top Bottom