简体   繁体   中英

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

回声“获取”“ /path/file.suf"|psftp存储的会话名称

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM