0

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 ?

aschipfl
  • 33,626
  • 12
  • 54
  • 99
Vincent Decaux
  • 9,857
  • 6
  • 56
  • 84
  • You need to use the `-b` switch of `psftp` and to provide a text file containing the `put` command line; the way you are doing it right now lets `put` be interpreted as a `cmd` (Windows command prompt) command... – aschipfl Sep 05 '16 at 12:43

1 Answers1

0

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.

Community
  • 1
  • 1
FloatingKiwi
  • 4,408
  • 1
  • 17
  • 41