Wildcard Character Using WinSCP.com

Advertisement

NoviceUser2018
Joined:
Posts:
4

Wildcard Character Using WinSCP.com

I have a simple script that needs to be automated. This script runs perfectly when I replace the * (wildcard character) with the actual filename. But throws a "No such file" error when using the *

Here's the script I'm currently using:

option batch abort
option confirm off
open sftp://MyUserName:MyPassword@URL:PortNumber -hostkey="HostkeyHere"
stat /dirName/*.enc
get /dirName/*.enc  c:\Users\MyUserName\Desktop\
close
exit

I call this from a windows batch script with this command in it:

winscp.com /ini=nul /script=C:\Users\MyUserName\Desktop\tstSftp\TestSFTP.txt /xmllog=C:\Users\MyUserName\Desktop\tstSftp\logSFTPTest.xml /loglevel=2


I searched for any similar existing issues on the forums, but I couldn't find one. I'm stuck. Please help.

Reply with quote

Advertisement

NoviceUser2018
Joined:
Posts:
4

Re: Wildcard Character Using WinSCP.com

NoviceUser2018 wrote:

I have a simple script that needs to be automated. This script runs perfectly when I replace the * (wildcard character) with the actual filename. But throws a "No such file" error when using the *

Here's the script I'm currently using:

option batch abort
option confirm off
open sftp://MyUserName:MyPassword@URL:PortNumber -hostkey="HostkeyHere"
stat /dirName/*.enc
get /dirName/*.enc  c:\Users\MyUserName\Desktop\
close
exit

I call this from a windows batch script with this command in it:

winscp.com /ini=nul /script=C:\Users\MyUserName\Desktop\tstSftp\TestSFTP.txt /xmllog=C:\Users\MyUserName\Desktop\tstSftp\logSFTPTest.xml /loglevel=2


I searched for any similar existing issues on the forums, but I couldn't find one. I'm stuck. Please help.

I just realized that Stat cannot be used with a wildcard character. And that's what is causing the error. Is there any way to check if a file extension exists using winscp.com script without using the WinscpNet libraries?

Reply with quote

NoviceUser2018
Joined:
Posts:
4

Re: Wildcard Character Using WinSCP.com

martin wrote:

Why do you even call the stat?

Hi Martin, I'am using stat so I can capture a message in the XML log when a file was not found. Please let me know if there is an alternative to using stat to get a comprehensive list in the XML log file - without having to go the dll route. Also if there are any other error/message log options/commands I can use.

Failonnomatch on
option produces a "unknown option 'failonnomatch'" error.

Reply with quote

NoviceUser2018
Joined:
Posts:
4

Re: Wildcard Character Using WinSCP.com

NoviceUser2018 wrote:

martin wrote:

Why do you even call the stat?

Hi Martin, I'am using stat so I can capture a message in the XML log when a file was not found. Please let me know if there is an alternative to using stat to get a comprehensive list in the XML log file - without having to go the dll route. Also if there are any other error/message log options/commands I can use.

Failonnomatch on
option produces a "unknown option 'failonnomatch'" error.

Just realized that the failonnomatch is a version issue. With the latest version of WinSCP.com portable, it works perfectly. Thanks!

Reply with quote

Advertisement

You can post new topics in this forum