connect windows share

Tim Golden mail at timgolden.me.uk
Wed Jun 22 14:59:48 EDT 2011


On 22/06/2011 19:38, Travis Altman wrote:
> I want to be able to connect to a windows share via python.  My end goal
> is to be able to recursively search through windows shares.  I want to
> do this in Linux as well.  So given a share such as \\computer\test I
> would like to search through the test directory and any sub directories
> for any file names of interest.  What's the best way of going about
> this?  I know LDAP / AD creds may play an essential part in this as
> well.  Thanks for your input.

Unless there's more to this than meets the eye, the answer's
really easy: just do it.

On Windows, you just do, eg:

import os

for dirpath, dirnames, filenames in os.walk (r"\\computer\test"):
   # do stuff with stuff

Presumably on Linux you have to use whatever mechanism allows
you to address Windows shares in the equivalent way. Maybe

os.walk ("smb://computer/test") ?? I'm not really a Linux person,
I'm afraid

TJG




More information about the Python-list mailing list