Open windows file explorer on Network Path

Hello everyone,

i’m having trouble browsing to a network location from Dash dcc.button.
i have used most common methods for that, including subprocess, open, os.system etc…

I had some success when Dash app running locally (windows machine) and browse over to localhost (127.0.0.1)
But it never worked on Linux server, when dash app is on Linux and clients are windows. (so the callback is working.)

I’m aware of the usage of 2 slash \ “\” to get 1 slash \ “\”, and also tried // / considering dash is running on Linux, didn’t found any mathcing set to work. the UNC path for the smb share i’m trying is : \192.168.6.10\Open or using DNS server locally: \fileserver\Open. Those options are working with subprocess.Popen and os.system(r’explorer “\192.168.6.10\Open”') when running locally, but not on Linux.

So this is the dcc.button, dash app is hosted on Linux machine on local network, clients are windows.

Thanks for any comments or suggestions.

image

Hi,
If you want to use SMB on Linux, you need to mount the target path first.

1 Like

the clients have that mounted. I just need the button to execute a local operation for browsing (clients are windows).
Does this still needs the Linux server , serving the dash app to have that mounted ?

Are you trying to have the clients pick a file from something accessible on their machine and not the server?

yes, the browsing will be done by the windows client through their browser.
The target is not open file, is browse to a network path SMB protocol.

Issues that you could run into with this would be mapped drives. Unless mapped drives also return the ip address of the mapped location?

SMB mounts also have to mount as a name, not sure if you can use an IP address for it.

You might be able to use something like this, where the user navigates to the address and file available from the server side:

Hello @jinnyzor , for local files (per your example) there is no problem. os.system is working fine.

The issue is for a network location that is SMB share, is working both with IP and also name , because of the local DNS server. So let’s focus on the problem !

Dash App, if running locally (my windows pc) and visit on 127.0.0.1 (localhost) , is working with os.system or subsystem open just fine !

IF now Dash app is running on a local Linux Server, which is accessible by the users with it’s IP or Hostname via a internet browser (ALL in Local LAN), the dcc.button is not working !

So i’m posting here so i can get more expertise suggestion from this forum. Thank you !

any ideas ?? i’m really stuck.

Windows server → windows client working
Linux Server → windows client not working

on both systems the SMB share is mounted and accessible and using os.system() function.

When you push the button, its supposed to open a file on the server?

When on the server, can you navigate to the path that you are trying to open from the CLI?

Hello Jinny, is suppose to open a network path SMB share \192.168.6.10\abc\abc
not a file. The location is accessible from both , windows and linux servers, serving the dash app.
Clients are all on windows. I’m using os.system() command in the function of callback.

What is the SMB mounted access point for it on the linux server? Is the button navigating to that directory?

yes, this is the print screen

should i use as location the “smb://fileserver.local/beyond/” OR "smb://192.168.6.10/beyond "
On debian files application both are working.

image

What user is running the linux server?

Does that user have permissions to access the SMB mount?

yes! just above you have a screenshot browsing a folder inside the share on the debian server serving the dash app.

Your logged in user is who is running the server through whatever means? Supervisor?

Not root or anyone else?

@jinnyzor hello !! i did some test on windows server , debian server with mounted and unmounted SMB shares so i can identify what is the problem.

the problem is that the command in dcc.button, for example
[subprocess.Popen(r’explorer /open,“\192.168.6.40\smb”') ] which is working , is not executed on the client web interface, is executed on the server !!!

for example, i have run dash app on windows server , and when the dcc.button is clicked and activate the subprocess.popen command, the command executed on the server system, because i found a lot of windows open on that path when i remote in.

So, is there any way to execute commands on the client side when dash app running on server ?

1 Like

Short answer no. Browsers won’t allow for control of users devices.

You could put the hyperlinked location as a navigation, and that might work.

Now, why are you wanting to open the file window though?

Try this:

Thank you @jinnyzor.
We are in the middle of developing systems , and we have a mess in the team on how we provide information to each other, so i setup a dash server locally to redirect all the information from a central location, that resides on the SMB local server.

so the option of link ‘file://///…’ works perfect on firefox, it just needs to hit enter again and is able to browse the SMB server within firefox while using the client permissions.
for chrome clients, ‘file://…’ works when right click-> copy link and then paste in new window.

So if the target goes to folder, that method is browsing the folder, if path going to file, that file is opening, for example excel file. Is enough for our purpose ! Thanks a lot.

1 Like