Topic "passing filemask as parameter"

Author Message
kang

Guest


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.
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
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.
kang

Guest


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.

martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
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
_________________
Martin Prikryl
Kang

Guest


Thanks. I finally got it working after a few tries.
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