How to read a file from another server? Newbie

S

Sean Berry

I am trying to read in a file from another server.

If I try
x = open("servername:/path/to/file", "r")

I get the following error:
IOError: [Errno 2] No such file or directory: 'servername:/path/to/file'


Sorry for the easy question, but couldn't find anything on google.

--
 
E

Edward Diener

Sean said:
I am trying to read in a file from another server.

If I try
x = open("servername:/path/to/file", "r")

x = open("servername://path/to/file", "r")
I get the following error:
IOError: [Errno 2] No such file or directory:
'servername:/path/to/file'
 
D

djw

Ivan said:
Um, what does this to? What protocol does it use?

I can see how this might work for a Windows server, but wouldn't the
forward slashes need to be back slashes? And the path to the file would
have to be a shared drive on the server.

-D
 
P

Peter Hansen

djw said:
I can see how this might work for a Windows server, but wouldn't the
forward slashes need to be back slashes? And the path to the file would
have to be a shared drive on the server.

"Might work" being the operative words. Actually "won't work"
is more correct, though. ;-)

Two points:

1. Forward slashes are perfectly fine on Windows,
provided you are not passing the path to the shell/command line/cmd.exe
or whatever. Internally Windows can cope with forward slashes very
nicely, and they often make it easier or more readable than resorting
to raw strings with r'path\file' all the time.

2. Its unlikely the server name should come first and with a colon
following. More likely //servername/path/to/file is closer to what
is wanted.

-Peter
 
S

Sean Berry

I have resolved the issue. I am just going to run the cgi script from the
server the file is on. If anyone out there is interested I am getting close
to finishing a script that does recursive digs for MX, A, and NS records for
a given domain, or list of domains.

Sean
 
S

Steve Holden

Sean said:
I have resolved the issue. I am just going to run the cgi script from the
server the file is on. If anyone out there is interested I am getting close
to finishing a script that does recursive digs for MX, A, and NS records for
a given domain, or list of domains.

Sean
Without in any way wishing to rain on your parade, dnspython
(http://www.dnspython.org/) is great for all DNS functionality.

regards
Steve
 
S

Steve Holden

Sean said:
I have resolved the issue. I am just going to run the cgi script from the
server the file is on. If anyone out there is interested I am getting close
to finishing a script that does recursive digs for MX, A, and NS records for
a given domain, or list of domains.

Sean
Without in any way wishing to rain on your parade, dnspython
(http://www.dnspython.org/) is great for all DNS functionality.

regards
Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top