[email protected]
[Top] [All Lists]

Re: [Samba] python: listing samba shares

Subject: Re: [Samba] python: listing samba shares
From: Ricardo Jorge
Date: Sun, 16 Aug 2009 22:25:18 +0100
> When just launching your code (with provided credentials), I have a segfault. 
> With the credentials code snippet removed, everything > works fine, and I can 
> see the shares listing! But when changing "localhost" to another ip address 
> (a windows machine), it fails:

About the segfault, I don't know why it happens. I found that it
happened (and already reported it) when creds.set_workstation was
omitted. I don't know what it could be in your situation.

Try this code instead. I changed the transport type to ncacn_ip_tcp.
It seems that you didn't need the credentials to do the smbclient
listing so you can also try removing them from there.

        conn = srvsvc.srvsvc('ncacn_ip_tcp:', credentials=creds)
except Exception, msg:
        print 'boooooo'
        print str(msg)
        ctr = srvsvc.NetShareInfoCtr()
        shares = conn.NetShareEnumAll(u'', ctr, 0, 0)

        print "\n\n============"
        print "There are " + str(shares[0].ctr.count) + " shares"
        print "============\n"

        for i in range(0, shares[0].ctr.count):
                share_info = info =
conn.NetShareGetInfo(u'', shares[0].ctr.array[i].name, 2)
                print share_info.name + "\t" + share_info.path + "\t "
+ share_info.comment

        print "\n\n"

> I would like to list remote samba shares contents (most of which are windows
> machines), not the local ones. So os.listdir() cannot help here.

You're correct, I forgot about that detail :) I couldn't find a
binding for this in the Python library.
To unsubscribe from this list go to the following URL and read the
instructions:  https://lists.samba.org/mailman/options/samba

<Prev in Thread] Current Thread [Next in Thread>