First, lets ensure that windows share is accesable:
$ sudo mkdir /mnt/test
Let's try mount, but it's fail:
$ sudo mount -t cifs //192.168.0.10/work /mnt/test
mount: wrong fs type, bad option, bad superblock on //192.168.0.10/work,
missing codepage or helper program, or other error
(for several filesystems (e.g. nfs, cifs) you might
need a /sbin/mount.<type> helper program)
In some cases useful info is found in syslog - try
dmesg | tail or so.
But if provide dummy user/pass (i.e. point exactly 'USERNAME' and 'PASSWD'), mount success:
$ sudo mount -t cifs -o username=USERNAME,password=PASSWD //192.168.0.10/work /mnt/test
$ ls /mnt/test/*.txt
/mnt/test/1.txt
$ umount test
Now lets try python:
$ python -V
Python 3.5.2+
$ python
>>> import os
>>> os.listdir(r'//192.168.0.10/work')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: '//192.168.0.10/work'
I'm trying four slashes, backslashes, combine it, with or without r
, unicode escaping (bytes(path, "utf-8").decode("unicode_escape")
), all this fail with No such file or directory
. May be reason of this fail is user/pass, but I have no imagine how add it to UNC.
ps. Also I try pysmb
library, it's work fine without user/pass. But I dont want using additional lib if it possible.