How do we list all files of a shared network directory using python?

Viewed 45

How can we list all files on a network shared directory of 2 network server shares, (which each running on Ubuntu SE & Windows SE respectively) in Python and add them to a tuple?

More Details:

Server: Windows SE, Ubuntu SE.

Client: Windows 10 Pro, Ubuntu 22.04

Python 3.10.4

Scenario: A (Listing a contents of local dir in Windows & Ubuntu)

As per following image, L4 to list dir from Windows 10 Pro client. L6 to list dir from Ubuntu Clent. [code for dir listing] 1

Scenario: A1 (Listing a contents of Network shared dir in Windows & Ubuntu)

A1_0

In case of both ends are windows env, following code is working; and gives lists of contents from the SERVER_SHARED_PATH (in L2).

import os
dir_path = r'//SERVER_IP/FILE_PATH/'
doc_path = os.listdir(dir_path)
doc_path_tuple = tuple(doc_path)
print(doc_path_tuple)

A1_1

In case, mixed env ( server is Windows SE & Client is Ubuntu DE), then following (python) code from Ubuntu DE gives lists of contents from the Windows SE SERVER_SHARED_PATH.

#help with python code needed for this to be clarified further

A1_2

In case, mixed env ( server is Ubuntu SE & Client is Windows 10 Pro), then following (python) code from Windows 10 Pro gives lists of contents from the Ubuntu SE SERVER_SHARED_PATH.

#help with python code needed for this to be clarified further

Thank You to everyone, who is contributing their knowledge to complete this Answer.
0 Answers
Related