Using variables in ftp connection by cmd

后端 未结 3 1570
逝去的感伤
逝去的感伤 2021-01-07 00:55

How I can use variables in ftp? This is what have i done: file a.bat:

set file=test ftp -s:b.txt IP

file b.txt

user password get %

3条回答
  •  囚心锁ツ
    2021-01-07 01:45

    ftp does not understand Windows environment variables. You have to generate your script file each time like this:

    set file=test
    set ftpscript=%TEMP%\ftp.txt
    echo user> %ftpscript%
    echo password>> %ftpscript%
    echo get %file%>> %ftpscript%
    echo quit>> %ftpscript%
    ftp -s:%ftpscript% IP    
    

    Here I have defined a temporary script in the temp directory so it does not pollute current directory.

提交回复
热议问题