Page 1 of 1

NAS resources access from Linux application

Posted: Fri Aug 16, 2024 1:48 pm
by Cezary
Dear Users,
in my application program running in Windows, I read some file from NAS in this way (using SAMBA):

Code: Select all

RunProgram("net", "use //mynas/myfolder/my_file /user:name password", "", #PB_Program_Hide)
This is a very convenient method when the NAS does not have a static IP.
Is there an equally simple way to do this in Linux?

Re: NAS resources access from Linux application

Posted: Fri Aug 16, 2024 1:54 pm
by NicTheQuick
What do you mean with reading a file? In your example you do not read a file. You only seem to authenticate against a samba share.

Re: NAS resources access from Linux application

Posted: Fri Aug 16, 2024 2:00 pm
by NicTheQuick
Usually you first need to install the package needed for that: `cifs-utils`. Then you can create a directory in which you want to mount the Samba share. Then you can mount it.
In the terminal it could look something like this:

Code: Select all

sudo apt-get install cifs-utils
sudo mkdir -p "$HOME/share_name"
mount.cifs //server_ip_or_hostname/share_name "$HOME/share_name" -o username=your_username,password=your_password,uid=$(id -u),gid=$(id -g)
Keep in mind that you have to replace $HOME and $(id -u) and $(id -g) accordingly before putting it in RunProgram.

Re: NAS resources access from Linux application

Posted: Fri Aug 16, 2024 2:52 pm
by NicTheQuick
Cezary wrote: Fri Aug 16, 2024 1:48 pm in my application program running in Windows, I read some file from NAS in this way (using SAMBA):

Code: Select all

RunProgram("net", "use //mynas/myfolder/my_file /user:name password", "", #PB_Program_Hide)
By the way. You are doing it wrong. `net use` also needs a free drive letter to mount the share to. And you can not mount single files, only whole folders. For me it looks like you never have tested the command you showed here.

Re: NAS resources access from Linux application

Posted: Fri Aug 16, 2024 3:08 pm
by Cezary
NicTheQuick,
with this file reading, I took a bit of a mental shortcut.
The procedure you provided works great, but only when I run it as superuser. Is there a way to do this without sudo?