Topic "Trying to set username variable in batch script"

Author Message
njleach

Guest


Hi,
So my server requires the username in the format: www.domain.com/email@address.com

This seems to cause problems when I attempt to put it all on the one line:
open sftp://www.domain.com/email@address.com:Password@www.domain.com

So I found another forum post where it is mentioned to use a variable for the username, by adding this line to the script:
set /P USERNAME="www.domain.com/email@address.com"

and then using %USERNAME% for the open script:
open sftp://%USERNAME%:Password@www.domain.com

When I try to run this it returns 'unknown command 'set'.'

My batch file is just simple:
WinSCP.exe /console /script=script.txt

and contents of script.txt:
option batch on
option confirm off
set /P USERNAME="www.domain.com/email@address.com"
open sftp://%USERNAME%:Password@www.domain.com
option transfer binary
put test2.txt /
exit

Any help appreciated!
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
The set command should be in a wrapping batch file, not in WinSCP script.
But it won't help you anyway. It makes no difference if you specify the username directly or via environment variable.

Solution is to URL-encode the slash and at sign:
open sftp://www.domain.com%2Femail%40address.com:Password@www.domain.com

See http://winscp.net/eng/docs/session_url
njleach

Guest


Thank you so much prikryl - URL-encoding the slash and @ symbol worked like a treat. Greatly appreciated! Very Happy

Nick
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