login about faq

Can I get the unix permissions also SFTP? Can not do anything with Posix and I absolutely need the PermType Unix.

Can you implement it? Thx Christian

asked Jul 20 '15 at 04:09

Christian's gravatar image

Christian
(suspended)


The SFtpFile.Permissions integer property is the Unix permissions.

link

answered Jul 20 '15 at 10:03

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

How can I translate this value Integer? Into 0644 maybe

Can you post an example?

link

answered Jul 20 '15 at 10:55

Christian's gravatar image

Christian
(suspended)

0644 is the octal representation of the integer.

An integer is a binary number -- a sequence of 1's and 0's. In binary, 0644 looks like this:

110100100

Displaying it as an octal number, each octal digit is 3 bits. Therefore we have this:

110 100 100

Displaying it as a hexidecimal number, each hex digit is 4 bits. Therefore we have this:

0001 1010 0100 (In hex this is 0x1A4)

In C/C++, you might use sprintf(buf,"%o",permVal);

link

answered Jul 21 '15 at 08:22

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

The return of GetFilePermission is not a binary value, it's a Long Value (Visual Basic):

I have researched many hours, here is my result:

perm = sftp.GetFilePermissions ("Test Folder", 0, 0)

'Perm = 16837' which is a Long value

OctPerm = Oct $ (perm) 'OctPerm = 40705

The first digit of 4 represents a folder, the rest behind the Unix permisson

perm = sftp.GetFilePermissions ("Test File", 0, 0)

'Perm = 33156' which is a Long value

OctPerm = Oct$(perm) 'OctPerm = 100604

The first two digits 10 stands for a file, the rest behind the Unix permisson

To change an access right now, I need to convert the value Long permisson into a octal number. Then I have to change the octal number, and then convert back again in a Long value to apply SetFilePermissions.

Private Function OctToDec (OctValue As String) As Long

Dim x As Long Dim value As Long

For x = 0 To Len (OctValue) - 1

Value = value + CLng (Mid $ (OctValue, Len (OctValue) - x, 1)) * 8 ^ x

Next

OctToDec = value

End Function

Or do I still have a flaw?

Greeting Christian

link

answered Jul 22 '15 at 01:59

Christian's gravatar image

Christian
(suspended)

In VB6 you have language provided ways to convert DEC<>OCT.

For example, converting a Base10 Decimal # to Base 8 Octal:

   Debug.Print Oct(33156)   ' Will print 100604 to the debug/immediate window

To convert from Octal to Decimal, prepend you octal number with &O and convert to Long as follows:

   Debug.Print CLng("&O" & 100604)   ' Will print 33156 to the debug/immediate window
link

answered Jul 22 '15 at 08:12

jpbro's gravatar image

jpbro ♦
1.1k2618

Thanks for the answer. But my function OctToDec also runs very well.

link

answered Jul 23 '15 at 08:22

Christian's gravatar image

Christian
(suspended)

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:

×200

Asked: Jul 20 '15 at 04:09

Seen: 845 times

Last updated: Jul 23 '15 at 08:22

powered by OSQA