Results 1 to 4 of 4

Thread: how to access samba share from python

  1. #1
    Join Date
    Feb 2007
    Beans
    72

    how to access samba share from python

    hi. i am writing a simple python script where i'd like to reference i file out on a samba share.

    in my konqueror its directory shows up as:
    smb://hs-d123as/share

    but when i use that in a python statement:
    f=open('smb://hs-d123as/share/workfile', 'w')

    it says it can't find the file.

    does anyone know how to reference this?

    btw it's on a terstation.

  2. #2
    Join Date
    Feb 2005
    Location
    Seattle
    Beans
    244
    Distro
    Ubuntu 7.04 Feisty Fawn

    Re: how to access samba share from python

    Hmmm. The "smb://" makes me think it's a url, which makes me think that urllib might dot he trick for you.

    Here's the reference:
    http://docs.python.org/lib/module-urllib.html

    Here's a sample:
    http://docs.python.org/lib/module-urllib.html

    HTH

    Cheers, Rick

  3. #3
    Join Date
    Sep 2006
    Beans
    2,914

    Re: how to access samba share from python

    if you want to do it in Python, try to look for some Python equivalent module. You can try this.

    From the shell, the smbclient command can do what you want. Check the man page for its basic syntax. something like :
    Code:
    # smbclient //host/share -Uusername -Ppassword -W domain .......
    Lastly, you can just provide a call to smbclient command through Python's subprocess module or popen()....however, i would recommend this to be the last resort.

  4. #4
    Join Date
    Feb 2007
    Beans
    72

    Re: how to access samba share from python

    thanks to you both, i used the mount command as indicated; now looking into how to make that permanent. i think it's somehow in fstab so will work on that next. thanks again.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •