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 %file%
quit
And log shows that there isn't any %file%.
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 %file%
quit
And log shows that there isn't any %file%.
This an example for uploading mutiple files:
This an example in batch just for testing that can list only files from a folder located on a public ftp server like ftp.microsoft.com in order to create a list.txt file to download it after, so give a try and tell us the result.
ftp does not understand Windows environment variables. You have to generate your script file each time like this:
Here I have defined a temporary script in the temp directory so it does not pollute current directory.
The reason the %-artifact didn't work in the BAT file was that that token was never seen and replaced. Just as in a UNIX shell script, $-substitutions are performed when those lines are collected and tokenized. Since the line containing the %file% was input to FTP, it was collected and parsed by FTP, not by the "DOS" shell.
In UNIX, you can solve this problem by piping the directives through FTP. That is to say, while this (where $1 is a filename parameter supplied on the command line):
wouldn't work, THIS:
WOULD work.