Continue on error is not working for permission denied error

Advertisement

atester
atester avatar
Joined:
Posts:
3

Continue on error is not working for permission denied error

I am running into a weird issue where the script will terminate on permission error. I did implement the method to continue on error and it's worked for various other cases, but this was the first I found that it doesn't continue.

$session.add_QueryReceived( { 
                   Write-Host "Error: $($_.Message)"
                   $continueOnError = $_.Message
                   $_.Continue()
                   if ($errorWhitelist -notcontains $logMessage){
                   Write-EventLog -LogName Application -Source "External_SFTP_Script" -EventID 101 -EntryType Warning -Message $continueOnError
                   }
                   Add-Content -Path $logFilePath "***continueOnError portion***`n $continueOnError`nEnd Error"
                   Add-Content -Path $logFilePath $Error
                } )

The below is what the log shows. For background, the filename Orphan Member list.xlsx was posted successfully previously and lived on the sftp server side. The following day the same file was placed into the \\outbound\ folder along with a copy of it name Orphan Member list_date.xlsx. So the script errored out on overwriting the same name, but it should've continued on error and then posted the Orphan Member list_date.xlsx file. So this is what was sitting in the outbound folder waiting to get picked up by the script:

    \\outbound\Orphan Member list.xlsx
    \\outbound\Orphan Member list_date.xlsx

However, the script was just terminated when it tried to overwrite the same file name. I can clarify if there is any confusion. Thanks!

> 2020-08-27 09:35:15.610 Script: pwd
< 2020-08-27 09:35:15.611 Script: /
> 2020-08-27 09:35:15.810 Script: put -delete -nopermissions -nopreservetime -transfer="binary" -resumesupport="off" -- "\\outbound\*" "/Inbound/"
. 2020-08-27 09:35:15.831 Copying 2 files/directories to remote directory "/Inbound/" - total size: 5,211,789
. 2020-08-27 09:35:15.832   PrTime: No; PrRO: No; Rght: rw-r--r--; PrR: No (No); FnCs: N; RIC: 0100; Resume: N (102400); CalcS: No; Mask: 
. 2020-08-27 09:35:15.833   TM: B; ClAr: No; RemEOF: No; RemBOM: No; CPS: 0; NewerOnly: No; EncryptNewFiles: Yes; ExcludeHiddenFiles: No; ExcludeEmptyDirectories: No; InclM: ; ResumeL: 0
. 2020-08-27 09:35:15.836   AscM: *.*html; *.htm; *.txt; *.php; *.php3; *.cgi; *.c; *.cpp; *.h; *.pas; *.bas; *.tex; *.pl; *.js; .htaccess; *.xtml; *.css; *.cfg; *.ini; *.sh; *.xml
. 2020-08-27 09:35:15.836 Getting real path for '/Inbound/'
> 2020-08-27 09:35:15.837 Type: SSH_FXP_REALPATH, Size: 18, Number: 272
< 2020-08-27 09:35:15.900 Type: SSH_FXP_NAME, Size: 37, Number: 272
. 2020-08-27 09:35:15.901 Real path is '/Inbound'
. 2020-08-27 09:35:15.902 File: '\\outbound\Orphan Member list.xlsx' [2020-08-26T19:09:06.604Z] [2605953]
. 2020-08-27 09:35:15.963 Copying "\\outbound\Orphan Member list.xlsx" to remote directory started.
. 2020-08-27 09:35:15.966 Binary transfer mode selected.
. 2020-08-27 09:35:15.967 Opening remote file.
> 2020-08-27 09:35:15.969 Type: SSH_FXP_OPEN, Size: 63, Number: 515
< 2020-08-27 09:35:16.073 Type: SSH_FXP_STATUS, Size: 36, Number: 515
< 2020-08-27 09:35:16.074 Status code: 3, Message: 515, Server: Permission denied, Language: en 
> 2020-08-27 09:35:16.075 Type: SSH_FXP_LSTAT, Size: 47, Number: 775
< 2020-08-27 09:35:16.159 Type: SSH_FXP_ATTRS, Size: 37, Number: 775
* 2020-08-27 09:35:16.160 (ETerminal) Permission denied.
* 2020-08-27 09:35:16.160 Error code: 3
* 2020-08-27 09:35:16.161 Error message from server (en): Permission denied
. 2020-08-27 09:35:16.162 Asking user:
. 2020-08-27 09:35:16.162 Cannot overwrite remote file '/Inbound/Orphan Member list.xlsx'.$$
. 2020-08-27 09:35:16.163  
. 2020-08-27 09:35:16.163 Press 'Delete' to delete the file and create new one instead of overwriting it.$$ ("Permission denied.
. 2020-08-27 09:35:16.164 Error code: 3
. 2020-08-27 09:35:16.164 Error message from server (en): Permission denied")
< 2020-08-27 09:35:16.165 Script: Cannot overwrite remote file '/Inbound/Orphan Member list.xlsx'.
< 2020-08-27 09:35:16.166 Script: Permission denied.
< 2020-08-27 09:35:16.166 Error code: 3
< 2020-08-27 09:35:16.167 Error message from server (en): Permission denied
* 2020-08-27 09:35:16.169 (ESkipFile) Cannot overwrite remote file '/Inbound/Orphan Member list.xlsx'.$$
* 2020-08-27 09:35:16.170  
* 2020-08-27 09:35:16.170 Press 'Delete' to delete the file and create new one instead of overwriting it.$$
* 2020-08-27 09:35:16.171 Permission denied.
* 2020-08-27 09:35:16.171 Error code: 3
* 2020-08-27 09:35:16.172 Error message from server (en): Permission denied
. 2020-08-27 09:35:16.172 Copying finished: Transferred: 0, Elapsed: 0:00:00, CPS: 0/s
. 2020-08-27 09:35:16.173 Script: Failed
> 2020-08-27 09:35:16.320 Script: exit
. 2020-08-27 09:35:16.321 Script: Exit code: 1
. 2020-08-27 09:35:16.322 Closing connection.
. 2020-08-27 09:35:16.322 Sending special code: 1
. 2020-08-27 09:35:16.386 Main session channel closed
. 2020-08-27 09:35:16.388 All channels closed
***NESTED CATCH ERROR****
 Exception calling "Check" with "0" argument(s): "Cannot overwrite remote file '/Inbound/Orphan Member list.xlsx'.$$
 
Press 'Delete' to delete the file and create new one instead of overwriting it.$$
Permission denied.
Error code: 3
Error message from server (en): Permission denied"
End Error
Exception calling "Check" with "0" argument(s): "Cannot overwrite remote file '/Inbound/Orphan Member list.xlsx'.$$
 
Press 'Delete' to delete the file and create new one instead of overwriting it.$$
Permission denied.
Error code: 3
Error message from server (en): Permission denied"

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
34,147
Location:
Prague, Czechia

Re: Continue on error is not working for permission denied error

Please attach full session (Session.SessionLogPath) and debug logs (Session.DebugLogPath).

Reply with quote

Advertisement

You can post new topics in this forum