ftp - putty - Replace FTP with SFTP to transfer files - PSFTP.EXE ONLY - answerstu - answerstu.com answerstu

putty - Replace FTP with SFTP to transfer files - PSFTP.EXE ONLY

I am currently FTP'ing file to a unix box from a windows server. I want to change the following section of the script and migrate the ftp process to be sftp.

@echo off
echo user %user%> ftpcmd.dat
echo %password%>> ftpcmd.dat
echo bin>> ftpcmd.dat
echo put %filetobeuploaded% %filepath%%File%>> ftpcmd.dat
echo quit>> ftpcmd.dat
ftp -n -s:ftpcmd.dat %host%
del ftpcmd.dat

I have PSFTP.EXE installed on my windows directory. Using that can I send the files with SFTP ?

How can I replace line ftp -n -s:ftpcmd.dat %host% to be SFTP. I understand you can do something like this....

CALL PSFTP.EXE someUserName@ ....

If anybody is familiar, please can you help me complete it. what arguments would I give. user, pw, remotedir, host details are kept in a properties file. Im looking to use keys instead of password. Can you pass the existing ftpcmd.dat arg to psftp?

1 Answer

  1. Brent- Reply


    You can also use WinSCP. It supports both the SFTP and scripting.

    See the guide for converting Windows FTP script to WinSCP SFTP script.

    The script will look like:

    open sftp://%user%:%password%@%host%
    put -transfer=binary %filetobeuploaded% %filepath%%File%

    You can run the script like (if saved to script.txt):

    winscp.com /script=script.txt

    Note that (contrary to the ftp.exe), environment variables are resolved in WinSCP script too.

    If you want to use a private key file, use:

    open sftp://%user%@%host% -privatekey=path\key.ppk

    (I'm the author of WinSCP)

Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>