473,399 Members | 4,192 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,399 software developers and data experts.

File permissions script vs shell

I'm running python on windows and have a program that watches a
directory and acts on files as they come into the directory. After
processing is complete, i delete the file, or in this case attempt
to....

In the script version I repeatedly get OSError exceptions stating
permission denied when trying to delete or rename

My exception print out...
Files system said no: [Errno 13] Permission denied:
u'D:\\Data\\00-0C-41-DD-87-E5.xml'

But i can go into the python shell and execute...

fileString = 'D:\\Data\\00-0C-41-DD-87-E5.xml'
import os
os.unlink(fileString)

and the file deletes fine

Any ideas? This is on my development windows xp box and i'm the only
user.

Thanks
Jeff

Jan 31 '06 #1
2 2126
jd*****@gmail.com wrote:
I'm running python on windows and have a program that watches a
directory and acts on files as they come into the directory. After
processing is complete, i delete the file, or in this case attempt
to....

In the script version I repeatedly get OSError exceptions stating
permission denied when trying to delete or rename

My exception print out...
Files system said no: [Errno 13] Permission denied:
u'D:\\Data\\00-0C-41-DD-87-E5.xml'

But i can go into the python shell and execute...

fileString = 'D:\\Data\\00-0C-41-DD-87-E5.xml'
import os
os.unlink(fileString)

and the file deletes fine

Any ideas? This is on my development windows xp box and i'm the only
user.


did you close the file correctly after processing it ?
f = open("somefile.txt", "w")
import os
os.remove("somefile.txt") Traceback (most recent call last):
File "<stdin>", line 1, in ?
OSError: [Errno 13] Permission denied: 'somefile.txt' f.close()
f = open("somefile.txt", "r")
os.remove("somefile.txt") Traceback (most recent call last):
File "<stdin>", line 1, in ?
OSError: [Errno 13] Permission denied: 'somefile.txt' f.close()
os.remove("somefile.txt")


</F>

Jan 31 '06 #2
Fredrik Lundh wrote:
jd*****@gmail.com wrote:
I'm running python on windows and have a program that watches a
directory and acts on files as they come into the directory. After
processing is complete, i delete the file, or in this case attempt
to....

In the script version I repeatedly get OSError exceptions stating
permission denied when trying to delete or rename

My exception print out...
Files system said no: [Errno 13] Permission denied:
u'D:\\Data\\00-0C-41-DD-87-E5.xml'

But i can go into the python shell and execute...

fileString = 'D:\\Data\\00-0C-41-DD-87-E5.xml'
import os
os.unlink(fileString)

and the file deletes fine

Any ideas? This is on my development windows xp box and i'm the only
user.


did you close the file correctly after processing it ?
f = open("somefile.txt", "w")
import os
os.remove("somefile.txt") Traceback (most recent call last):
File "<stdin>", line 1, in ?
OSError: [Errno 13] Permission denied: 'somefile.txt' f.close()
f = open("somefile.txt", "r")
os.remove("somefile.txt") Traceback (most recent call last):
File "<stdin>", line 1, in ?
OSError: [Errno 13] Permission denied: 'somefile.txt' f.close()
os.remove("somefile.txt")


</F>


That was correct...i started to see it just after posting, the open
file was hidden behind the 4Suite library via the FromUri method.
Reading the xml file as a string and passing it to fromString instead
and closing the file myself solved this.

Jeff

Jan 31 '06 #3

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

Similar topics

7
by: LRW | last post by:
Sorry to crosspost, but I have no idea if this is more a PHP question of general Linux question. I have a script that makes changes to image files, montages them into a jpg, and creates a Web...
4
by: uwb | last post by:
I've got a call to glob in a .py file sitting in an apache cgi-bin directory which refuses to work while the exact same code works from a python console session. I'm guessing that in order to...
14
by: Mark C. | last post by:
I'm trying to call a batch file that I've built using the FileSystemObject and CreateObject("Wscript.Shell"), oShell.Run... in an asp script. Naturally, I can get the script to work from a command...
13
by: Leo | last post by:
Hi I had asekd previously a question qith regards to running a DLL file from ASP. It was not running for me. Bo error returned, nothing, Just an empty string (when it should have not been...
9
by: Ben Dewey | last post by:
Project: ---------------------------- I am creating a HTTPS File Transfer App using ASP.NET and C#. I am utilizing ActiveDirectory and windows security to manage the permissions. Why reinvent...
10
by: John Salerno | last post by:
I always read about how you need to set certain file permissions (for cgi files, for example), but it's never been clear to me *how* you do this. I know you can run the line chmod 755...
6
by: rahulthathoo | last post by:
Hi I have my home directory on my departments server. Somehow I am not able to write to a file using a php code, $myFile = "trial3.txt"; $fh = fopen($myFile, "a+") or die("can't open file"); ...
30
by: Adam Baker | last post by:
Hello, I'm writing a site where a handful of people will be able to edit the content using PHP scripts (FCKeditor). The content is stored as individual files in a directory. I'd like to validate...
4
by: cryogeneric | last post by:
Hello everyone, :) I can't seem to get around some annoying permission issues when I attempt to run a quick test where I call a batch file from my ASP script. I'm running this on my XP Pro...
13
by: eclipsme | last post by:
I thought I had this licked, but apparently not. I have a file upload script that attempts to upload a file to a directory in the public_html directory - www.domain.com/upload The permissions...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...
0
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,...
0
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...

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.