[SOLVED] setting an environment variable - it doesn't seem to work
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
setting an environment variable - it doesn't seem to work
I'm trying to configure the lirc remote control software, but I'm hoping someone can help me even if they are not familiar with lirc.
My lirc commands are failing because they are pointing to an interface called /usr/local/var/run/lirc/lircd, when in fact the program is listening on /var/run/lirc/lircd (without the /usr/local prefix)
The manpage has this entry:
ENVIRONMENT
LIRC_SOCKET_PATH
The lircd socket to connect to, defaults to a hardcoded default value /usr/local/var/run/lirc/lircd
So the hard coded value is obviously my problem. The manpage made me think I could change an environment variable called LIRC_SOCKET_PATH to point in the correct place, and I would be good to go.
So I edited /etc/environment to add a line "LIRC_SOCKET_PATH=/var/run/lirc/lircd".
I logged out and back in, and I get:
mary@mythbox:~$ printenv | grep lir
LIRC_SOCKET_PATH=/var/run/lirc/lircd
so it looks like it worked. But then when I run the lirc program (irsend, if it matters), it still fails because it is trying to point to the hard-coded interface of /usr/local/var/run/lirc/lircd
Is there something about the manpage that I am misunderstanding? If something is hard-coded, am I SOL and if so, what is the point of having an environment variable for it?
Usually you set environmental variables either on the command line from which you launch your program or on a per-session basis in one of your login files (usually .profile or .bash_profile). The second method is probably better because it works for graphically launched programs too.
Try putting that line in your personal profile, then log out and log in again.
OPTIONS
-h --help
Display usage summary.
-v --version
Display version.
-d --device=device
Use given lircd socket [/usr/var/run/lirc/lircd].
-a --address=host[:port]
Connect to lircd at this address.
-# --count=n
Send command n times.
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,800
Rep:
Quote:
Originally Posted by mstrimel
I'm trying to configure the lirc remote control software, but I'm hoping someone can help me even if they are not familiar with lirc.
My lirc commands are failing because they are pointing to an interface called /usr/local/var/run/lirc/lircd, when in fact the program is listening on /var/run/lirc/lircd (without the /usr/local prefix)
What do you mean by "failing"? "File not found?" Permissions? Are there error messages you can post?
Quote:
LIRC_SOCKET_PATH
The lircd socket to connect to, defaults to a hardcoded default value /usr/local/var/run/lirc/lircd
So the hard coded value is obviously my problem. The manpage made me think I could change an environment variable called LIRC_SOCKET_PATH to point in the correct place, and I would be good to go.
Rather than editing and creating s system-wide environment variable (unless other users will need it, then go ahead), I would write a quick-n-dirty wrapper script (in, say, "$HOME/bin") that either uses the information that 'teckk' suggested:
If neither of those work, post whatever error messages you are receiving. It's, uh, pretty hard to tell what's going wrong when you can't see the failure.
Offhand I cannot tell what is wrong, but if it doesn't work, try a different approach: create a link to this socket at the desired location or remount /var/run/lirc at /usr/local using mount --bind
Thanks everyone for your helpful suggestions. A piece of information I should have provided is that another user, "mythtv," needs to be able to run the lirc commands to change channels for my linux PVR system, that is why I was seeking a universal environmental variable. Luckily for me, the mythtv channel change script has a config file where you can set a device to override the hard-coded one. So, problem solved, once I realized I should look there, although I'm still baffled as to why setting an environment variable as described in my first post did not work. (For those who asked ... the error was 'no device found' on /usr/local/var/run/lirc/lircd, and the logs clearly showed that lircd was listening on /var/run/lirc/lircd).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.