Passing local parameter to remote session

Advertisement

blumko
Joined:
Posts:
1
Location:
Slovakia

Passing local parameter to remote session

Dear friend,

Please help me with such a problem: I want to pass a variable stored current date to my remote session and create there new folder with the name of that variable (e.g. 20140611). I tried some combination, mostly got an error "Missing parameter for the command mkdir". The last version of my batch script is:
@ECHO OFF
cls
date <nul >~datetime.txt
for /f "eol=E tokens=5-9 delims=/ " %%i in (~datetime.txt) do (
set month=%%j
set day=%%k
set year=%%l
)
set timestamp=%year%%month%%day%

WinSCP.exe /console /parameter timestamp /command "open sftp://exchange:ut9k3cm0@10.213.114.3:22" "mkdir %1%"

Please, what have I wrong? Thank you in advance for help.

Reply with quote E-mail

Advertisement

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

Re: Passing local parameter to remote session

First, typically you want to execute a winscp.com from a batch file, instead of winscp.exe.
See https://winscp.net/eng/docs/executables

blumko wrote:

WinSCP.exe /console /parameter timestamp /command "open sftp://exchange:ut9k3cm0@10.213.114.3:22" "mkdir %1%"
You need to use %timestamp% syntax to make Windows expand the variable name.

Though there's no point passing a value of an environment variable as parameter when you can resolve it directly in the command:
WinSCP.com /command "open sftp://exchange:ut9k3cm0@10.213.114.3:22" "mkdir %timestamp%"

Reply with quote

Advertisement

You can post new topics in this forum