4

Using this library: https://pypi.python.org/pypi/PySmbClient I am trying to access a file from my Ubuntu machine via a smb share from a windows machine.

The share is up and running fine and I can see the files but, when I try to access the files from a Phyton script, I keep getting this error:

<SambaClient('topit/topit'@'//oberon/depot')>
Traceback (most recent call last):
  File "runTest.py", line 56, in <module>
    f = smb.open('estimate.sql')
  File "/home/matejb/Development/dcm-test/smbclient.py", line 408, in open
    f = _SambaFile(self, path, mode)
  File "/home/matejb/Development/dcm-test/smbclient.py", line 448, in __init__
    connection.download(remote_name, self._tmp_name)
  File "/home/matejb/Development/dcm-test/smbclient.py", line 393, in download
    result = self._runcmd('get', remote_path, local_path)
  File "/home/matejb/Development/dcm-test/smbclient.py", line 184, in _runcmd
    return self._raw_runcmd(fullcmd)
  File "/home/matejb/Development/dcm-test/smbclient.py", line 168, in _raw_runcmd
    stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
  File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

My code:

import smbclient

smb = smbclient.SambaClient(server="oberon", share="depot",
                                username='topit', password='topit', domain='topit')
print smb

f = smb.open('estimate.sql')
data = f.read()

print data
Rahul
  • 10,830
  • 4
  • 53
  • 88
Jacob
  • 3,580
  • 22
  • 82
  • 146
  • Did you get a solution? I have the same problem while accessing files on the windows server! – Anu Oct 07 '19 at 21:24

1 Answers1

-1

Try

sudo apt-get update && sudo apt-get install -y --no-install-recommends smbclient

Because it works by running the "smbclient" subprocess

e1ee1e11
  • 31
  • 3
  • smbclient is present that's why he can see the files on his machine. Same error for me! The connection is established but can't fetch the file from the windows file server. – Anu Oct 07 '19 at 22:34