Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
listdir on IP Adress
#1
Hallo Guys,

I need to get content of a windows "networkshare".
It is and will not be added as networkdrive with a letter.

In Windows Explorer I can resolve the content via "\\192.168.5.1"
--> dir1
--> dir2


With Python I am trying
import os
d=os.listdir('\\\\192.168.5.1')
and differnt version of slashes

--> In the best case I get: FileNotFoundError: [WinError 67]


any help
Reply
#2
that ip address links to several domains see: https://whois.domaintools.com/192.168.5.1
it seems to connect to none of them, thus your File Not Found error
Reply
#3
@Larz60+ it's a private IP in his home network or somewhere else behind a router.

The easy short solution is, to mount your samba share to a drive letter.
Then you can use open(), os.listdir and other operations on file system.

You can't use open or other file system operations like os.listdir on a samba share.
You can access with a client the samba share: https://pypi.org/project/smbprotocol/
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply
#4
For whatever reason, although you can list the contents of the shares, you don't seem to be able to list the shares themselves. On my windows 10 machine:

>>> len(os.listdir('//10.0.0.10'))  # fails to list the shares by IP
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
FileNotFoundError: [WinError 67] The network name cannot be found: '//10.0.0.10'

>>> len(os.listdir('//10.0.0.10/USB_Storage'))   # listing contents of a share works fine
84
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  trouble with os.listdir on a network drive lconner 10 19,129 Jun-04-2019, 07:16 PM
Last Post: DeaD_EyE
  creating an 'adress book' in python using dictionaries? apollo 6 14,833 May-06-2019, 12:03 PM
Last Post: snippsat
  Default pip adress xxp2 3 2,491 Jan-31-2019, 02:10 PM
Last Post: buran
  os.listdir(path) and non-string as input metalray 4 16,710 Aug-15-2018, 11:43 AM
Last Post: metalray
  listdir trouble Dixon 1 2,632 Jan-17-2018, 11:32 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020