How can I get permission to mask the files like 644 or 755 using nix * using Python? Is there a function or class to do this? Can you help me Thanks a lot!
From here you will recognize typical octal permissions. If you are really only interested in short bit , so you can cut the rest: Sidenote: Upper parts filetype, set for example: OSSTAT is a cover around the system call interface.
& gt; & Gt; & Gt; Import OS & gt; & Gt; & Gt; From State Imports * & gt; & Gt; & Gt; Os.stat ("test.txt") returns # 10 tupel, you really want 0 element ... posix.stat_result (st_mode = 33188, st_ino = 57,197,013, \ st_dev = 234881026L, st_nlink = 1, st_uid = 501, st_gid = 20, st_size = 0, \ st_atime = +13003546 9 7, st_mtime = +13003546 9 7, st_ctime = +13003546 9 7) & gt; & Gt; & Gt; Osstat ("test.txt") [ST_MODE] # This is an integer, but we like the Octagon ... 33188> & Gt; & Gt; From October (os.stat ("test.txt") [ST_MODE]) '0,100,644'
S_IRUSR 00,400 owners allow S_IWUSR 00200 Owner read S_IRWXU to the permissions of the file owner 00700 mask allow S_IXUSR about 00,100 owners allow S_IRWXG executed 00,070 masks group permissions 00,020 group S_IRGRP allow S_IXGRP about 00010 group permission to execute 00040 group not allowed to read the permissions for others (group S_IWGRP) read S_IWOTH S_IRWXO 00007 mask 00004 others allow S_IROTH 00002 write permissions others S_IXOTH is 00001 amount execute others allow
& gt; & Gt; & Gt; Act (osstate ("test.txt") [ST_MODE]) [- 3:] '644' & gt; & Gt; & Gt; # Or better & gt; & Gt; & Gt; October (os.stat ( "test.txt") st_mode & amp; 0777.)
S_IFMT 0170000 bitmask file type bitfield S_IFSOCK 0140000 socket S_IFLNK 0120000 Signal link S_IFREG 0100000 Regular file S_IFBLK 0060000 Block device S_IFDIR 0040000 Directory S_IFCHR 0020000 character device S_IFIFO 0010000 FIFO S_ISUID 0004000 set UID bit S_ISGID 0002000 set-group-id bit (below) See) S_ISVTX 0001000 sticky bit (see below)
Comments
Post a Comment