Script to download files non-recursively - failing permission denied

Advertisement

SBH
Joined:
Posts:
2

Script to download files non-recursively - failing permission denied

Hi, I'm trying to download files from an Sftp site with a basic power shell script based on the excellent one from here. I'm trying to download files ending with D.zip created in the last day from the root of the XML directory. The files are only from the root as the ID I'm using to access the directory doesn't have permissions to the sub directories. However when the script runs it doesn't download anything as it fails with the error below. The directory 1000 is one the ID has no permission too.

Error listing directory '/XML/1000'.
Permission denied.
Error code: 3

Error message from server (en): Permission denied.

The file mask I'm trying is FileMask = "*D.zip>=1D|*/"

Any help would be greatly appreciated. Script file attached.
Description: power shell script

Reply with quote

Advertisement

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

Re: Script to download files non-recursively - failing permission denied

Your code looks OK to me, except that $remotePath should probably be "/XML/*". Or even "/XML/*D.zip>=1D" straight away (and you won't need the TransferOptions).

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

To generate the session log file, set Session.SessionLogPath. 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

SBH

Thank you

Thanks Martin, that's fixed the issue. Setting the file mask in the remote directory variable stops the lack of permissions to the sub directories causing the problem.

Many Thanks

Reply with quote

Advertisement

You can post new topics in this forum