NAS resources access from Linux application

Just starting out? Need help? Post your questions and find answers here.
Cezary
Enthusiast
Enthusiast
Posts: 110
Joined: Sun Feb 12, 2017 2:31 pm

NAS resources access from Linux application

Post 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?
User avatar
NicTheQuick
Addict
Addict
Posts: 1527
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: NAS resources access from Linux application

Post 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.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
User avatar
NicTheQuick
Addict
Addict
Posts: 1527
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: NAS resources access from Linux application

Post 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.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
User avatar
NicTheQuick
Addict
Addict
Posts: 1527
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: NAS resources access from Linux application

Post 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.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
Cezary
Enthusiast
Enthusiast
Posts: 110
Joined: Sun Feb 12, 2017 2:31 pm

Re: NAS resources access from Linux application

Post 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?
Post Reply