From: utabintarbo on
Until now, I have used the UNC under Windows (XP) to allow my program
to access files located on a Samba-equipped *nix box (eg.
os.path.normpath(r"\\serverFQDN\sharename\dir\filename")). When I try
to open this file under Linux (Red Hat 5), I get a file not found
error.

Is there a cross-platform method for accessing files on a network
share using Python 2.X?

TIA
From: cassiope on
On May 7, 7:32 am, utabintarbo <utabinta...(a)gmail.com> wrote:
> Until now, I have used the UNC under Windows (XP) to allow my program
> to access files located on a Samba-equipped *nix box (eg.
> os.path.normpath(r"\\serverFQDN\sharename\dir\filename")). When I try
> to open this file under Linux (Red Hat 5), I get a file not found
> error.
>
> Is there a cross-platform method for accessing files on a network
> share using Python 2.X?
>
> TIA

normpath will convert forward slashes to backslashes on WinXX systems,
but
does not seem to do the reverse on posix systems...so try changing
your
string to use forward slashes. Also- is the path otherwise the same
on
your Linux system?

HTH..
-f
From: utabintarbo on
On May 7, 11:23 am, cassiope <f...(a)u.washington.edu> wrote:
>
> normpath will convert forward slashes to backslashes on WinXX systems,
> but
> does not seem to do the reverse on posix systems...so try changing
> your
> string to use forward slashes.  Also- is the path otherwise the same
> on
> your Linux system?
>
> HTH..
>   -f

I tried forward slashes:

lst_p = open(os.path.normpath('//serverFQDN/sharename/dir/
filename'),'r').readlines()

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: [Errno 2] No such file or directory: '//serverFQDN/sharename/
dir/filename'

BTW, this works on WinXP.

It is as if it does not resolve, yet I have '//serverFQDN/sharename'
mounted, proving that it does resolve. Is this an issue with the way
python deals with the network? It does not seem like a network-only
issue.
From: News123 on
Hi TIA,

utabintarbo wrote:
> Until now, I have used the UNC under Windows (XP) to allow my program
> to access files located on a Samba-equipped *nix box (eg.
> os.path.normpath(r"\\serverFQDN\sharename\dir\filename")). When I try
> to open this file under Linux (Red Hat 5), I get a file not found
> error.
>
> Is there a cross-platform method for accessing files on a network
> share using Python 2.X?
>

Up to my knowledge there is now path name under linux, which gives you
access to samba shares without mounting then.


Perhaps there's some special user space file system drivers providing
that functionality, but I don't expect it to be standard linux behaviour.

What is your linux distribution?

I would suggest to change the subject line to something like:

"accessing samba shares from a linux host without mounting them"

or "cross-platform liibrary to access samba shares"

From: Tim Roberts on
utabintarbo <utabintarbo(a)gmail.com> wrote:
>
>Until now, I have used the UNC under Windows (XP) to allow my program
>to access files located on a Samba-equipped *nix box (eg.
>os.path.normpath(r"\\serverFQDN\sharename\dir\filename")). When I try
>to open this file under Linux (Red Hat 5), I get a file not found
>error.
>
>Is there a cross-platform method for accessing files on a network
>share using Python 2.X?

No. On Linux, you need to mount the share in some empty directory (using
mount or smbmount), then read the files from that directory.

It's kind of odd to use a Windows network protocol to access a Linux file
system from another Linux machine.
--
Tim Roberts, timr(a)probo.com
Providenza & Boekelheide, Inc.