0

I need to run this chain of commands

psftp xx.xx.xx.xx -l xxx -pw yyy
cd zzzzzz
get file.csv
bye

in one single command line

(psftp comes from here: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html)

I have seen on superuser (https://superuser.com/a/532528/290138) that with ftp you can do it like this but I don't understand how it works:

echo open xx.xx.xx.xx >> ftp & echo user xxx yyy >> ftp & echo binary >> ftp & echo get file.csv >> ftp &echo bye >> ftp & ftp -n -v -s:ftp & del ftp

Thanks!

[EDIT]
I wrote those 4 lines in a .bat file and ran it.
The first line executes well, but then the psftp interpreter opens (it's like the ftp interpreter)
and the second line never happen

Community
  • 1
  • 1
stallingOne
  • 3,633
  • 3
  • 41
  • 63
  • write a `.bat` file with all the commands in it, then execute that "one" command from the command line. You realize your example cmd is creating a script, (with suspect syntax) and running it and then deleting it? So you can do the same thing with `.bat` files. Good luck. – shellter Nov 10 '16 at 16:41

2 Answers2

1

echo "get" "/path/file.suf"|psftp stored-session-name

0

I figured it out finally:

Create a .bat file that does this:

cd X:\where\you\want\to\download

@echo off 
@echo cd xxx > psftp.txt
@echo get yyy.csv >> psftp.txt
@echo bye >> psftp.txt

psftp xx.xx.xx.xx -l login -pw PW -b psftp.txt

del psftp.txt

or chain all of these with & to have it in one line.

stallingOne
  • 3,633
  • 3
  • 41
  • 63