473,386 Members | 1,773 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,386 software developers and data experts.

os.tmpfile() -> permission denied (Win XP)

Hi,

Here's what's happening:

Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
| >>import os
| >>os.tmpfile()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 13] Permission denied

but tempfile.mkstemp() works:
>>import tempfile
tempfile.mkstemp()
(3, 'c:\\docume~1\\sjm\\locals~1\\temp\\tmpnfuk9i')

This is Windows XP Pro SP2. The user with the problem is _not_ an
administrator. It works OK when logged on as an administrator. I am
using the mode which enables having multiple users logged on and
switching between them.

The problem happens with Pythons back to 2.2. Python 2.1 on Windows
doesn't seem to have a tmpfile() function in the os module.

On a Windows 2000 SP4 box, with a "Power User" [part way between
administrator and vanilla user] Python 2.3.5 os.tmpfile() works OK.
AFAICT Win XP doesn't have this intermediate level of user.

Questions:
1. Before I start checking what permissions who has to do what to
which, what directory is it likely to be trying to open the temp file
in? C:\WINDOWS\TEMP....?
2. What is the general advice about whether to use os.tmpfile() or the
functions in the tempfile module? I'm presuming that as os.tmpfile()
is ultimately calling tmpfile() in the C stdio library, nobody would
have gone to the effort of making the tempfile module just to
reproduce stdio functionality, but AFAICT there's no guidance in the
docs. Maybe I should be talking to the authors of the package that is
using os.tmpfile() :-)

TIA for any clues,
John

Feb 11 '07 #1
3 8231
En Sun, 11 Feb 2007 01:57:52 -0300, John Machin <sj******@lexicon.net>
escribió:
| >>os.tmpfile()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 13] Permission denied

1. Before I start checking what permissions who has to do what to
which, what directory is it likely to be trying to open the temp file
in? C:\WINDOWS\TEMP....?
You could analyze the source, but usually I find easier to use FILEMON:
http://www.sysinternals.com

--
Gabriel Genellina

Feb 11 '07 #2
On Feb 11, 4:15 pm, "Gabriel Genellina" <gagsl...@yahoo.com.arwrote:
En Sun, 11 Feb 2007 01:57:52 -0300, John Machin <sjmac...@lexicon.net>
escribió:
| >>os.tmpfile()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 13] Permission denied
1. Before I start checking what permissions who has to do what to
which, what directory is it likely to be trying to open the temp file
in? C:\WINDOWS\TEMP....?

You could analyze the source,
I have already followed the twisty little passages: os.tmpfile() is
really nt.tempfile(), but there is no Modules/ntmodule.c (Modules/
posixmodule.c does a Jekyll & Hyde trick). (nt|posix)module calls
tmpfile(), which is (as I mentioned) in the C stdio library. How can I
analyse the source of that? Have Microsoft had a rush of blood to the
head and gone open source overnight??
but usually I find easier to use FILEMON:http://www.sysinternals.com
Thanks, I'll try that.

Cheers,
John

Feb 11 '07 #3
On Feb 11, 4:33 pm, "John Machin" <sjmac...@lexicon.netwrote:
On Feb 11, 4:15 pm, "Gabriel Genellina" <gagsl...@yahoo.com.arwrote:
En Sun, 11 Feb 2007 01:57:52 -0300, John Machin <sjmac...@lexicon.net>
escribió:
| >>os.tmpfile()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 13] Permission denied
1. Before I start checking what permissions who has to do what to
which, what directory is it likely to be trying to open the temp file
in? C:\WINDOWS\TEMP....?
You could analyze the source,

I have already followed the twisty little passages: os.tmpfile() is
really nt.tempfile(), but there is no Modules/ntmodule.c (Modules/
posixmodule.c does a Jekyll & Hyde trick). (nt|posix)module calls
tmpfile(), which is (as I mentioned) in the C stdio library. How can I
analyse the source of that? Have Microsoft had a rush of blood to the
head and gone open source overnight??
but usually I find easier to use FILEMON:http://www.sysinternals.com

Thanks, I'll try that.
While Filemon is still alive, it's been superceded by Procmon, which
combines filemon + regmon + plus new goodies. I tried procmon.

And the result of an administrator user doing os.tmpfile():
281773 4:50:14.8607126 PM python.exe 2716 CreateFile C:\t2ks SUCCESS
Access: Generic Read/Write, Delete, Disposition: Create, Options:
Synchronous IO Non-Alert, Non-Directory File, Delete On Close,
Attributes: N, ShareMode: Read, Write, Delete, AllocationSize:
3,184,748,654,057,488,384
[big snip]

*** AARRGGHH It's creating the file in the *ROOT* directory ***

A quick google for "tmpfile root directory" reveals that this is a
"popular" problem on Windows. See e.g. http://bugs.mysql.com/bug.php?
id=3998 which has several users corroborating the story, plus this
handy hint:
"""
But MSDN says (ms-help://MS.MSDNQTR.2003APR.1033/vclib/html/
_crt_tmpfile.htm):
-------
The tmpfile function creates a temporary file and returns a pointer to
that stream. The temporary file is created in the root directory. To
create a temporary file in a directory other than the root, use tmpnam
or tempnam in conjunction with fopen.
"""

I wonder why my environment has entries for TMP and TEMP (both
pointing to the same path, and it sure ain't the root directory) --
must be one of those "haha fooled you" tricks :-(

Regards,
John

Feb 11 '07 #4

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

Similar topics

1
by: Benny | last post by:
Dear All, My ASP-MS Access application works fin in our local server and in our hosting I get this errors, while adding/editing or deleteing. When deleting a product: error Microsoft VBScript...
2
by: Taishi | last post by:
New user of SQL Everything is on the same machine My error is close to the bottom After reading it today, I can see there is a problem with 2 dbases 'PUBS' and 'Master' There are also some...
3
by: johkar | last post by:
My child window has this script. "temp" is simply the value of the select list which I am passing onchange. I get a permission denied error in IE when executing selectOption. function...
21
by: alistair_henderson | last post by:
Morning All, I have some code for a website which uses 'window.open' to simulate modal dialog boxes. I use the window.closed property to decide if the window object exists at various points. ...
0
by: cyberco | last post by:
Opening, reading and writing to a file works fine in mod_python, but using fileinput (with inplace editing) gives me a 'permission denied' with exactly the same fileName: ...
0
by: debug03 | last post by:
I am executing a DTS package on a Windows 2000 sp4 server running SQL Server 2000 and IBM DB2 V7 client. The DTS package source data(SQL Server) is selected from SQL server table and inserts data to...
0
by: private.anders | last post by:
Hi David! Really need assistance since I have been struggling with a problem long time now. I am running a web application on a Win 2003 Std (Active Directory). Everything works fine. I have...
0
by: private.anders | last post by:
Really need your assistance since I have been struggling with a problem long time now. I am running a web application on a Win 2003 Std (Active Directory). Everything works fine. I have...
4
by: xzzy | last post by:
I have a v1.1 web app that works on my local computer. However, running it at the host computer, the following breaks: when a viewer selects a different country, the State dropdown should...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.