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

Author Message
[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
"C:\Program Files\WinSCP\WinSCP.exe" /console /script="c:\winscpftp.txt"
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@
option transfer binary
cd /%w%/%m%/%a%
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
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26890
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

You can post new topics in this forum


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!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License