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 %
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.