I ma trying to open a file on a network share
ie \\servername\sh are\folder\file
afile = open( \\server\share\ folder\file, "r" )
have also tried
afile = open( //server/share/folder/file, "r" ) # as per the Python cookbook
advice on page 113 namely " use / regardless of the proclivities of the
underlying operating system".
Neither work.
I am running python on XP and accessing win 2000 share.
Thanks for any help
Graham Smith
PeopleSoft Technical Team Leader
OXFAM GB
+44 (1865) 313255 gs****@oxfam.or g.uk 4 14471
Graham,
path=r"\\server name\sharr\fold er\file.ext"
works on my machine (I use it all the time).
Remember that backslash is an "escape" character so
you must us r"<path>" or double the number of backslashes
without the "r":
path="\\\\serve rname\\share\\f older\\file.ext "
-Larry Bates
"Graham" <gs****@oxfam.o rg.uk> wrote in message
news:40******** **************@ reading.news.pi pex.net... I ma trying to open a file on a network share
ie \\servername\sh are\folder\file
afile = open( \\server\share\ folder\file, "r" )
have also tried afile = open( //server/share/folder/file, "r" ) # as per the Python
cookbook advice on page 113 namely " use / regardless of the proclivities of the underlying operating system".
Neither work.
I am running python on XP and accessing win 2000 share.
Thanks for any help
Graham Smith
PeopleSoft Technical Team Leader OXFAM GB +44 (1865) 313255 gs****@oxfam.or g.uk
What's the error? Can you provide a trceback?
Regards
Franz
P.S.: Im not sure but accessing a share on a machine NOT connected to a
network doesn't work since 2k and XP (worked on NT, though).
"Graham" <gs****@oxfam.o rg.uk> schrieb im Newsbeitrag
news:40******** **************@ reading.news.pi pex.net... I ma trying to open a file on a network share
ie \\servername\sh are\folder\file
afile = open( \\server\share\ folder\file, "r" )
have also tried afile = open( //server/share/folder/file, "r" ) # as per the Python
cookbook advice on page 113 namely " use / regardless of the proclivities of the underlying operating system".
Neither work.
I am running python on XP and accessing win 2000 share.
Thanks for any help
Graham Smith
PeopleSoft Technical Team Leader OXFAM GB +44 (1865) 313255 gs****@oxfam.or g.uk
Graham wrote: I ma trying to open a file on a network share
ie \\servername\sh are\folder\file
afile = open( \\server\share\ folder\file, "r" )
have also tried afile = open( //server/share/folder/file, "r" ) # as per the Python cookbook advice on page 113 namely " use / regardless of the proclivities of the underlying operating system".
Are the above actual examples of the code you typed? If so, I suggest
reviewing the tutorial... strings in Python always require surrounding
quotation marks, either ' or ", and yours above have neither.
works like a champ.
using
'//server/share'
'\\\\server\sha re'
r'\\server\shar e'
C:\Documents and Settings\cary>p ython
ActivePython 2.3.2 Build 231 (ActiveState Corp.) based on
Python 2.3.2 (#49, Nov 6 2003, 10:18:20) [MSC v.1200 32 bit (Intel)] on
win32
Type "help", "copyright" , "credits" or "license" for more information. import os os.listdir('//pollux/hdc1')
['public', 'archive', 'store'] os.listdir('\\\ \pollux\\hdc1')
['public', 'archive', 'store'] os.listdir(r'\\ pollux\hdc1')
['public', 'archive', 'store']
BTW, thanks. I hadn't thought of using UNCs
"Graham" <gs****@oxfam.o rg.uk> wrote in message
news:40******** **************@ reading.news.pi pex.net... I ma trying to open a file on a network share
ie \\servername\sh are\folder\file
afile = open( \\server\share\ folder\file, "r" )
have also tried afile = open( //server/share/folder/file, "r" ) # as per the Python
cookbook advice on page 113 namely " use / regardless of the proclivities of the underlying operating system".
Neither work.
I am running python on XP and accessing win 2000 share.
Thanks for any help
Graham Smith
PeopleSoft Technical Team Leader OXFAM GB +44 (1865) 313255 gs****@oxfam.or g.uk This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: simon place |
last post by:
is the code below meant to produce rubbish?, i had expected an exception.
f=file('readme.txt','w')
f.write(' ')
f.read()
( PythonWin 2.3 (#46, Jul 29 2003, 18:54:32) on
win32. )
I got this while experimenting, trying to figure out the file objects modes,
|
by: Matthew Wilson |
last post by:
I have a bunch of classes that track data for time series. The classes are
really just glorified dicts where the key is a date object, and the value is the
value as of that date.
I want a way to store a bunch of these tseries objects into a file object. I
want to be able to open the file object, iterate through all timeseries, then
create...
|
by: Dan Perl |
last post by:
Here is some code to illustrate a problem that I have:
import copy
class myc:
def __init__(self):
self.myf=file('bar.txt',"w")
def foo(self):
self.myf.write('hello world!') # it's going to fail for
d.foo( )
c = myc()
|
by: John Marshall |
last post by:
Hi,
Does anyone see a problem with doing:
data = file("tata").read()
Each time this is done, I see a new file
descriptor allocated (Linux) but not
released.
1) Will there ever be a point where I
|
by: Matthew Thorley |
last post by:
I've been using tarfile like this
import tarfile
tar = tarfile.open('path_to_tar_archive', 'r:gz')
But I need to use it like this:
archive = open('path_to_tar_archive', 'r')
tar = tarfile.open(archive.readlines())
| |
by: travis ray |
last post by:
Hi,
I have an extension in which a file object is created in python and
passed down to a c extension which attempts to read from it or write
to it. Writing to the file pointer seems to work okay, but reading
from it results in EBADF. It also causes python to crash on exit.
I've attached the minimal (I think) c code, python code, build...
|
by: troutbum |
last post by:
I am experiencing problems when one user has a document open through a
share pointing to the web site. I use the dsolefile to read the
contents of a particular directory and then display them in a
datalist. When the next user selects trys to run the page, the page
fails and I get a generic error message from the stack trace. I am
assuming...
|
by: John Salerno |
last post by:
What is the best way of altering something (in my case, a file) while
you are iterating over it? I've tried this before by accident and got an
error, naturally.
I'm trying to read the lines of a file and remove all the blank ones.
One solution I tried is to open the file and use readlines(), then copy
that list into another variable, but...
|
by: Michael Castleton |
last post by:
When I open a csv or txt file with:
infile = open(sys.argv,'rb').readlines()
or
infile = open(sys.argv,'rb').read()
and then look at the first few lines of the file there is a carriage return
+
line feed at the end of each line - \r\n
This is fine and somewhat expected. My problem comes from then writing
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |