batch-fileputtypsftp

Using PSFTP to send file to remote server


I have a bat file I call everynight to transfer some files.

I want to put a file from my computer to my remote server. I have installed PSFTP and I don't know how to use it in batch way.

I put this :

CD /D C:\Users\Vincent\Desktop
psftp user@99.99.99.99 -pw password -P port
put file.csv /remote/folder/file.csv

But when I call my BAT file, it stucks on :

psftp > _

How can I use it as automate mode ?


Solution

  • You need to create a file which contains the commands you wish to run. In this case

    put file.csv /remote/folder/file.csv
    

    Then pass that file with the -b option to PSFTP.

    See https://stackoverflow.com/a/16440468/6550457 for an example.

    using PSFTP as you have will open it in interactive mode which is why you get the prompt. The -b will run it in batch mode.