NI Linux Real-Time Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Logging programmatically

I want to move files around on my Linux target. I tried using the "mv" command and also the Move Files.vi. But they both say I don't have the correct permission. So I tried doing it from command line and to get the "mv" to work I needed to use "su - admin" command and then put in the password. Then I can move files around. But I can't get it to work from my VI. I tried using the System Exec.VI and send "su - admin" but that didn't work. What is the best way to login in order to move files around?

0 Kudos
Message 1 of 6
(5,180 Views)

It all depends on the actual files that you want to move around. What files are you looking at trying to work with?

0 Kudos
Message 2 of 6
(3,982 Views)

You helped me before mount the folder which is working well, but I am pretty sure that my IT department is keeping me from giving read/write access to a general user on Linux. I found I can put files into that mounted folder if I move the files from a folder where I do have read/write access into the mounted folder. But I can only move the files if I am logged in. The files will be data files, but I'm not sure if they are tdms or csv. Right now they are just .txt.

0 Kudos
Message 3 of 6
(3,982 Views)

@LJHerskowitz,

There are two main usernames that we work with on our NI Linux Real-Time targets:  lvuser and admin.  Admin will allow you to make changes all over the filesystem, whereas lvuser will restrict permissions only to the location /home/lvuser.  Because of security issues with having admin accessible through LabVIEW, LabVIEW uses the lvuser username to perform functions.  If a file exists outside /home/lvuser or a directory with read/write permissions given to lvuser, the functions you are using will not work.

This is a common issue with any GNU/Linux distribution and there is a lot of documentation out there that will allow you to become familiar with file permissions and directory locations in Linux.  I would suggest looking online for documents related to "understanding file permissions in Linux" as an example.  The documents that exist should clarify a few things about the filesystem and read/write permissions.

Attempting to use the 'su admin' command also requires input from a user at a prompt for a password.  The 'su' command has been designed in a way that there is not a method to automatically input a password, nor is there a method in LabVIEW to interact with a command line other than the System Exec.vi.  The System Exec.vi only allows you to submit a single command and receive a response, which means you cannot enter a password as a second prompt.  This effectively means that you cannot become admin to move files around on the NI Linux Real-Time system.  There are ways around this, however.

Sudo is a third-party package (that requires some configuration, also available by searching and reading documentation online) that allows you to become a superuser (admin) in-line with a command.  You would be able to issue the command 'sudo mv <file> <location/file>' and it would grant the correct permissions and perform the operation when configured correctly.  There are many security issues with doing this, but if you are intent on using other directories that your lvuser does not have permission to access, it would allow you to read/write to them.  You would need to install this third-party package in a similar fashion to some of your previous endeavors with opkg.  I would highly recommend gaining a better understanding of the filesystem and permissions before you go this route, since it leads to many, many security issues on your device.  You should be able to work safely in the /home/lvuser directory and assign read/write permissions to other folders from a console using the admin login instead...again, after a good understanding of file permissions in Linux. 

Hopefully that helps in your understanding of what is going on with the permissions.  Do some searching and reading up on Linux file permissions, then let us know if you have any further questions!

| Zach J. | Systems Engineer, HIL and Test Cells | National Instruments |
Message 4 of 6
(3,982 Views)

The issue is that, normally, when mounting a network share, you are doing so with admin/root privileges, meaning that you are unable to add files to the folder as a normal user. You can check this with the command "ls -l" on the folder that contains the empty folder you are using as a mountpoint.

E.g.:

You are mounting the Windows share to /home/lvuser/natinst/LabVIEW Data/share

ls -l /home/lvuser/natinst/LabVIEW\ Data/

This will give you the ownership and permissions of the folders within this directory. By default, the permissions will be root (admin), preventing you from writing to the folder.

There is an optional parameter that you can pass to the mount.cifs command to define the userID/groupID that you wish to use for the mount, this should make it available to the lvuser and, thereby, from the G diagram (since LabVIEW is running as lvuser). I'd try to add a "-o ...uid=lvuser..." to your command.

Message 5 of 6
(3,982 Views)

That worked. Thanks.

0 Kudos
Message 6 of 6
(3,982 Views)