for loop variable in winscp ftp script dont work

Advertisement

soly
Joined:
Posts:
1
Location:
egypt

for loop variable in winscp ftp script dont work

Dear friends
i am trying to automate winscp ftp session and i start as follow :


i got a DOS batch file .bat looks like
------------------------------------------------------
@echo off
set w=work
set m=macro
set a=test
FOR %%X IN (AAA BBB) DO (
"C:\Program Files\WinSCP\WinSCP.exe" /console /script="c:\winscpftp.txt"
/log="c:\log.log"
ECHO %%X
)
---------------------------------------------------------
note: the patch work well and the variable %X appearers in the echo command correctly

also note that the for loop variable is written %%X and not %X



and i got a winscp ftp script looks like
---------------------------------------------------------
option confirm off
open ftp://root:password@192.9.200.30
option transfer binary
cd /%w%/%m%/%a%
dir
get %X%
----------------------------------------------------------

when running the batch file it lunches the winscp console and it work well tell the point =====> get %X% and it return the error

Can't get attributes of file '%X%'.
File or folder '%X%' does not exist.

i try to modify the winscp script to be =====> get %%X but the same error appears

plz help me to get the right way to get the variable from the batch for loop

thank you all

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,454
Location:
Prague, Czechia

For loop variables are not environment variables, hecne they are not propagated to child processes. You may store the loop variable value to env variable though using set shell command.

Reply with quote

Advertisement

You can post new topics in this forum