stallingOne
stallingOne

Reputation: 4006

How to chain psftp commands in one single windows command line

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

Upvotes: 0

Views: 2644

Answers (2)

Danila Ermakov
Danila Ermakov

Reputation: 19

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

Upvotes: 1

stallingOne
stallingOne

Reputation: 4006

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.

Upvotes: 0

Related Questions