Cannot access SMB mounts using scripts - 'No such file or directory'

I have a working NAS which appears in file manager as smb://ts216g/public/ but if I try to use this path in shell scripts, python scripts, or command line it errors with ‘No such file or directory’.

The file manager can access the whole NAS without permissions violations.

How can I specify a location on the NAS in a script?

Because - in my limited understanding - that is not a PATH
It is a network address.

Perhaps find the mount point - or first have the file manager mount the share to some mount point and then use that. :man_shrugging:

2 Likes

Yes, I’m sure you’re right, but there doesn’t appear to be any mount point in the filesystem. All access appears to be through the smb:// network protocol. The file manager just makes objects look the same as local objects. And if I dump a file name into an editor it shows %20 for spaces.

This is a bit disappointing. I can access all files on the NAS from RISC OS just the same as local files, so I can automate procedures through scripts. I’d still like to know if anyone has any ideas how to do this from Linux. Is there a hidden API in a file manager perhaps, or can smbclient be used under program control? I can’t find any ready-made answers, which is why I asked here.

We have already had this - RISC OS is different, works differently.

It has been a long time since I used samba or any other network file system, but it should not be too difficult.
Although I seldom ever use graphical file managers - I just can’t describe how it would work only with Thunar, which you seem to prefer - or with Dolphin or whatever.

The Arch wiki is usually the best place of information - but they won’t describe how to handle your graphical tools.

Basically, you mount your samba share (using its protocol and address) to some directory of your choice.
That directory IS your mount point, through which you can access the share by PATH.

Samba - ArchWiki

I’m sure much has bee written about samba/smb/cifs here on the forum as well.

here you are, for example:

Thunar: How do I access folders shared on Windows computers?

Another hint re Thunar

https://superuser.com/questions/1645590/thunar-cannot-browse-network

I think the package is called gvfs-smb in Arch/Manjaro.
Something with gvfs in the name.

The mount utility doesn’t allow mounting a SAMBA share. It could potentially be automounted via /etc/fstab, but that isn’t considered very reliable.

If the gvfs-smb package is installed, that should allow you to access your share via the file manager.

sudo pacman -Syu gvfs-smb --needed

I use Dolphin (KDE) and my memory of Thunar is sketchy, at best; you might need to create a Network Location before you can access it.

In Dolphin, this was done from the Network folder/module but for Thunar, you’ll need to find how to do that yourself.

I hope this helps. Cheers.

You will have to mount on a predefined location - then unmount when done.

I created a script a couple of years ago - you could see it for ideas on how you could accomplish your goal

[root tip] [Utility Script] GIO mount samba share

And for a modified version see

Re: [Utility Script] GIO mount samba share - #3 by pheiduck

This works well. I can now push files to the NAS from python scripts. Thank you very much!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.