From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
02-09-2024 12:00 PM - edited 02-12-2024 04:19 PM
I've created a custom environment variable for the lvuser (i.e. MYPATH=/tmp/mydir). Now I want my LabVIEW application to read this environment variable, but when I use the System Exec.vi to call "echo $MYPATH", it returns blank. If I ssh into the RT, su to lvuser, and type the same thing, I get what I expect. What is the issue with doing this from the System Exec.vi in LabVIEW?
UPDATE 2/12/2024:
I created a VirtualBox with NI Linux RT (https://www.youtube.com/watch?v=s15gM5b635M) to continue testing this issue while the PXI is unavailable, and I am able to see the environment variable in the virtual machine just fine. So, I will have to continue investigating why I cannot get the same behavior from the embedded PXIe-8880 controller.
02-11-2024 05:48 AM
I don't have access to an LV RT instance to verify it for myself... Is there a chance that the shell in which your environment variable was declared is not the same one used by LV's System Exec call?
02-11-2024 09:56 AM
@Dhakkan wrote:
I don't have access to an LV RT instance to verify it for myself... Is there a chance that the shell in which your environment variable was declared is not the same one used by LV's System Exec call?
As someone who does a fair amount on Linux ( not RT just general Linux) this is most likely the problem. That or it is running as a different user.
02-11-2024 09:59 AM
Actually right after I hit send I seem to recall - don’t try progams run as lvuser or something. When you ssh are you logging in as lvuser - if so then that may be your problem.
intsead of env variables you could try storing it in a file - although you have be careful about permissions and iirc lvrt programs run in some kind of chroot? So you’ll have to make sure your lvrt program can find it.
02-12-2024 03:12 PM - edited 02-12-2024 03:18 PM
Thank you for the reply Taggart. I have been logging in as admin, then su lvuser to ensure the environment variable is set for lvuser.
Also, yes, the LV program runs as lvuser. I can use the System Exec.vi to run, "whoami" and it returns "lvuser".
Interestingly, running "env" through System Exec.vi yields a very small subset of the lvuser's environment variables. Basically, just PWD which has the value of the directory in which the LV program is stored, and SHLVL which equals 1. Perhaps this is why the environment variable is not accessible because the program is running in a lower level shell where the profile has not been updated?
Unfortunately, it seems like I will have to store the variable in a file.
02-13-2024 12:43 AM
@BrantZ wrote:
Interestingly, running "env" through System Exec.vi yields a very small subset of the lvuser's environment variables. Basically, just PWD which has the value of the directory in which the LV program is stored, and SHLVL which equals 1. Perhaps this is why the environment variable is not accessible because the program is running in a lower level shell where the profile has not been updated?
Does it not even include SHELL, to indicate what shell is being used?
@BrantZ wrote:
Unfortunately, it seems like I will have to store the variable in a file.
Perhaps you could try one more thing before resorting to a file approach - set the value at a system level in the /etc/ folder. There are multiple options, the following two links can give you a gist:
NOTE: You may wish to use the man pages of the actual environment, rather than the generic one above.