Topic "for loop variable in winscp ftp script dont work"

Author Message
soly
[View user's profile]

Joined: 2010-10-20
Posts: 1
Location: egypt
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
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
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.
_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License