passing filemask as parameter

Advertisement

kang
Guest

passing filemask as parameter

HI,
I had created some script templates for code reusing. The basis template created are working well.

However, as the demands get more complicated. I found that I'll need to pass switches in as parameter to do filtering. Somehow when I try to do that, I am encountering errors. When I hard code the switches in the script template, it's working.

Following is a working sample template:
option batch abort
option confirm off
option transfer binary
open %1% -privatekey="%2%" -hostkey="%3%"
get -filemask=*>1D "%5%" "%4%"
close
exit

Pls advice how can I change the switches to accept parameter. Is it possible in the first place?

Thanks.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: passing filemask as parameter

Please attach a full log file showing the problem (using the latest version of WinSCP).

To generate log file, use /log=path_to_log_file command-line argument. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.

Reply with quote

kang
Guest

passing filemask as parameter

HI,
Pls see the log file attached.

Sensitive data have been masked.

This is how I made the call to pass parameters:

--------------------------------
C:\"Program Files (x86)"\WinSCP\winscp.exe /log=D:\FolderA\UAT\ProductB\SFTPSCRIPTS\LOG\MaskedSwitchLog_20150414.log /script=D:\FolderA\UAT\PROCESS\sftpScp_GetMaskedFile.txt /parameter userloginID@HostIP:PortNum D:\SFTPKEYS\ProductB\PartnerC\user_PartnerC.ppk "HostKeyMasked" D:\FolderA\UAT\ProductB\FolderB\PartnerC "/XYZ" "-filemask=*>1D"
---------------------------------

legend for above:
/log = path for log file output
/script = path for script template
/parameter 1st=userid, host IP & port num, 2nd=path for private key file, 3rd=Host Key, 4th=local Dir 5th=remote Dir 6th=switch


Following is the sample of the script template which is to take in the parameters:

----------sample---------------
option batch abort
option confirm off
option transfer binary
open %1% -privatekey="%2%" -hostkey="%3%"
get "%6%" "%5%" "%4%"
close
exit
----------sample---------------

Parameter %6% is the parameter for switch.

Not sure is the above the correct way of doing. Pls enlighten me.

Thanks.
  • MaskedSwitchLog_20150414.log (12.91 KB, Private file)
Description: Sensitive data have been masked.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: passing filemask as parameter

OK, WinSCP recognizes the /filemask=*>1D as command-line switch, instead of a parameter of the script.

Just prefix the parameter list with // to avoid them ever being interpreted as switches.

C:\"Program Files (x86)"\WinSCP\winscp.exe /log=D:\FolderA\UAT\ProductB\SFTPSCRIPTS\LOG\MaskedSwitchLog_20150414.log /script=D:\FolderA\UAT\PROCESS\sftpScp_GetMaskedFile.txt /parameter // userloginID@HostIP:PortNum D:\SFTPKEYS\ProductB\PartnerC\user_PartnerC.ppk "HostKeyMasked" D:\FolderA\UAT\ProductB\FolderB\PartnerC "/XYZ" "-filemask=*>1D"

See https://winscp.net/eng/docs/commandline#scripting

Reply with quote

Advertisement

You can post new topics in this forum