473,322 Members | 1,188 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

weird problem with os.chmod

Ok, so now I have a very interesting problem, this time related to
os.chmod. I have the following in a text file: 0600. My script reads
that number as a string and converts it to an integer for use with
chmod. However, when I do this, instead of the rw------ permissions
that I expect, I get ---x-wx--T. I tried placing 0600 directly in the
command (chmod(filename, 0600)), and that worked as expected (I got
rw------). So then I entered the command print 0600, and saw that the
actual number being output was 384 (why would it output 384?!) I put
384 in place of 0600 (chmod(filename, 384)), and again I got what I
wanted (rw------). So, I guess the number 0600 is actually being
converted to 384. However, this leaves me with the question: how
exactly do I go about getting the number 0600 from my file and turning
it into something I can use? int(string) gives me 600, not 384 (which
results in the funky permissions.) If I could figure out how Python was
converting 0600 to 384, I could try to emulate that behavior in my
script. Any input would be greatly appreciated.

James

--
My blog: http://www.crazydrclaw.com/
My homepage: http://james.colannino.org/

"A well regulated militia being necessary to the security of a free
state, THE RIGHT of the people to keep and bear arms SHALL NOT BE
INFRINGED." --United States Constitution, Second Ammendment

Nov 12 '05 #1
1 2953
On Fri, 11 Nov 2005 16:49:23 -0800, James Colannino wrote:
Ok, so now I have a very interesting problem, this time related to
os.chmod. I have the following in a text file: 0600. My script reads
that number as a string and converts it to an integer for use with
chmod. However, when I do this, instead of the rw------ permissions


0600 is the octal representation of 384. "man chmod" should help you.
Just use
perm = int(string, 8)
instead of
perm = int(string)
when converting to int the string you read from the file.
--
Saluti,
Mardy
http://interlingua.altervista.org

Nov 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Daniel | last post by:
Hi, From what I read from the PHP manual, chmod on a Windows platform should have no effect, and that seems totally normal (unless someone on sourceforge has a windows port of that!). I...
6
by: Ask Josephsen | last post by:
Hi NG If I write the following: <?php $file="myfile.JPG"; if ( getmyuid()==fileowner ( $file ) ) { chgrp ( $file, getmygid() ); chown ( $file, getmyuid() );
1
by: Xuan Yuan | last post by:
I'm using Windows XP Professional and have no FTP installed. Instead, I use Command Promt. I need to CHMOD a PHP file, so I type "CHMOD 775 file-path",but get "'CHMOD'is not recognized as an internal...
5
by: Stewart | last post by:
Hi, I'm working on a program in VC++ right now that needs to set file permissions of a given file to 766 (read/write/execute). Now I've found the _chmod() function in the API help docs, but that...
2
by: Freebird | last post by:
Hello everyone, =] I need your help, I'm creating a script that will work in many servers, and there's this part, where you can update a list, so the script goes from the client's machine to...
8
by: NurAzije | last post by:
Hi, I wonder is there a way or a function to take a high resolution image and change it to low resolution ?? I have a directory with a 200 pictures, and want to save them with the same width and...
37
by: John Salerno | last post by:
I contacted my domain host about how Python is implemented on their server, and got this response: ------------------- Hello John, Please be informed that the implementation of python in our...
3
by: webhead | last post by:
I have a web where users can upload photos, but they want to also be able to delete them. The directory can have chmod changes but it won't let me chmod the files and unlink them. I'm assuming it...
1
by: softy1 | last post by:
I am having problem in chmod permission settings Here is script <?php $uploaddir = $_POST; $dirsplit = $uploaddir; list($var1, $var2) = explode('/', $dirsplit);...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.