weird problem with os.chmod

James Colannino james at colannino.org
Fri Nov 11 19:49:23 EST 2005


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




More information about the Python-list mailing list