LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   Variable not accessible when service is starting (http://www.linuxquestions.org/questions/linux-server-73/variable-not-accessible-when-service-is-starting-4175448872/)

hogar.strashni 02-06-2013 08:02 AM

Variable not accessible when service is starting
 
Hello everybody.

First, I'll generalize my problem. I have a file in /etc/profile.d/ directory that exports variable DISPLAY, and a services that demands variable DISPLAY in order to get started. Though DISPLAY variable is present, service script cannot access it during execution. Why?

I'm using CentOS 6.3

------------------------------------------------------------------------------------------------------------------------

To elaborate the problem: I'm trying to run Sahi and Selenium as daemons that outputs to Xvfb, and though I exported DISPLAY during startup, both Selenium and Sahi cannot see it when starting. On the other hand ,everything works fine if I put DISPLAY variable within service(Sahi or Selenium) starting script.

Finally, code look like this:
/etc/profile.d/xvfb.sh
Code:

export DISPLAY=:99
echo $DISPLAY returns :99

Relevant part of service starting script when service doesn't work: /etc/init.d/sahid.sh
Code:

./start_dashboard.sh
Relevant part of service starting script when service DOES work: /etc/init.d/sahid.sh
Code:

DISPLAY=":99" ./start_dashboard.sh
All that means that it can't access variable DISPLAY :( Again - why?

Hope I didn't miss the forum for the problem I have.

slinx 02-06-2013 01:17 PM

Each service is started in its own subshell, with its own environment variables. They are non-interactive shells, so they do not source the system-wide profiles. You must place any variable definitions within that service's init script or configuration file.


All times are GMT -5. The time now is 02:55 PM.