1

Can I pass the content of the batch file directly as argument instead of saving it in a batch file and passing the file itself?
My question is the following, instead of using this:

psftp.exe user_name@host_domain -pw user_pw -b example_batch_file.bat

example_batch_file.bat content:

get filename.csv

I would like to use something like this (in one go, not manually opening the console and doing it one after another, its for automatisation purpose):

psftp.exe user_name@host_domain -pw user_pw -get filename.csv
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
KTFLash
  • 63
  • 1
  • 5

1 Answers1

1

The psftp can read the commands from the standard input.

So you can do:

(
  echo get filename.csv
  echo other command
) | psftp.exe user_name@host_domain -pw user_pw

If you really need one-liner, then:

( echo get filename.csv && echo other command ) | psftp.exe user_name@host_domain -pw user_pw

Though note that psftp also reads answers to its prompts from the standard input. So you will want to add -batch switch to disable all prompts and make psftp automatically fail instead.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992