login about faq

Hi Chilkat,

I am uploading files, then setting trying to set permissions to the file, but getting an error.

Code: 
        success = sftp.SetPermissions("foldername/test1.txt", False, 777)
        If (success <> True) Then
            Console.WriteLine(sftp.LastErrorText)
            sb_LogDebug(sftp.LastErrorText)
            Exit Sub
        End If

Using Chilkat 9.5.0.51

The details of the log are below:

ChilkatLog: SetPermissions: DllDate: Jun 23 2015 ChilkatVersion: 9.5.0.51 UnlockPrefix: CRMSOL.CB10716 Username: CRMNB5:tim Architecture: Little Endian; 64-bit Language: .NET 4.5 / x64 VerboseLogging: 0 SshVersion: SSH-2.0-OpenSSH_5.9 SftpVersion: 3 filename: fujitsu/test1.dat isHandle: 0 octalPermissions: 1411 FileAttr_v3: permissionsHex: 0x309 --FileAttr_v3 StatusResponseFromServer: Request: SetPermissions InformationReceivedFromServer: StatusCode: 4 StatusMessage: Failure --InformationReceivedFromServer --StatusResponseFromServer Failed. --SetPermissions --ChilkatLog

asked Sep 10 '15 at 21:22

Lambomania's gravatar image

Lambomania
11

edited Sep 11 '15 at 00:27

Gert's gravatar image

Gert ♦
629141824


I found this reference about SFTP status codes on the web: https://winscp.net/eng/docs/sftp_codes

"Unfortunately, OpenSSH SFTP server uses always description “Failure”. Is such case, there is unfortunately no way to tell a reason of the failure."

link

answered Sep 11 '15 at 00:28

Gert's gravatar image

Gert ♦
629141824

I suspect the error is from an invalid permissions value (i.e. the bit flags may make no sense). You're passing decimal 777 in this code:

Code: 
        success = sftp.SetPermissions("foldername/test1.txt", False, 777)
        If (success <> True) Then
            Console.WriteLine(sftp.LastErrorText)
            sb_LogDebug(sftp.LastErrorText)
            Exit Sub
        End If

The correction is to specify the permissions using the octal literal representation in the programming language you are using. For example, it might be this:

Code: 
        success = sftp.SetPermissions("foldername/test1.txt", False, 0777)
        If (success <> True) Then
            Console.WriteLine(sftp.LastErrorText)
            sb_LogDebug(sftp.LastErrorText)
            Exit Sub
        End If

link

answered Sep 11 '15 at 08:37

chilkat's gravatar image

chilkat ♦♦
11.8k316358421

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×201

Asked: Sep 10 '15 at 21:22

Seen: 645 times

Last updated: Sep 11 '15 at 08:37

powered by OSQA