473,626 Members | 3,298 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2975
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
16808
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 create a directory on my Windows box, and set chmod 777 on it (that should be full access for everyone if my memory serves me correctly), but when I want to rmdir that directory, I get a permission denied message (I can delete contents from that...
6
6684
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
4693
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 or external command,operable program or batch file"!Is this because I spelled it wrong?Or is it the computer's problem?
5
9542
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 only caters for read/write. Is there ANY way of setting 766 to a file through C++ at all? Many thanks. Mike
2
2911
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 the central server, opens the file, and in adda line by line in the client server, it's all working fine, but there's a problem, this list, can't be available to others, because if I do this:
8
2310
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 height but with another lower resolution, can I do it automaticly with a script, not downloading them, changing them with image program and uploading them again.. Thank you
37
2468
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 server is through mod_python integration with the apache. These are the steps needed for you to be able to run .py script directly
3
3763
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 really is a chmod problem even though the error message is "no such file or directory", as I'm sure the name and path are right. Even my ftp program won't let me chmod the files, is this a safemode problem?
1
1797
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); if(!(is_dir(realpath("/uploads")))) { mkdir("uploads/".$var2."/", 0777); }
0
8642
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8368
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7203
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5576
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4094
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4206
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2630
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1515
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.