LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Environmental variables .bashrc (https://www.linuxquestions.org/questions/linux-general-1/environmental-variables-bashrc-815374/)

Skillz 06-21-2010 03:37 AM

Environmental variables .bashrc
 
I have a slight problem that I don't fully understand.

I'm running a couple UT game servers on a Linux box and have been doing so for quiet some time now with no problems. I only recently went to install another instance of a game server, from scratch, with the same user as the other server(s) installed already. I use a special script to handle the stopping/starting of the server, not sure if it's relevant.

Anyway, here is my dilemma. Prior to installing the 3rd installation, I had no issues. Once I started trying to install the third one, I started running into problems. Problems with the game saying that the $UT_DATA_PATH wasn't set correctly. Something I had no issues with before. So I did some research and the command echo $UT_DATA_PATH turned up an empty string. So I thought, let me add this. So I edited the .bashrc file to export UT_DATA_PATH=/path/ to the newly installed game server instance.

Well, everything seemed to work fine until I restarted the other two game servers after taking them down briefly for some small updates. In the logs, I was getting "Failed to load" errors saying it couldn't load the map that was set for the start up. I checked directory to make sure the map and permissions were all correct and no problems their.

It wasn't until I thought that maybe it was because of the UT_DATA_PATH, so I deleted the entry in the .bashrc file. To my dismay, echo $UT_DATA_PATH still turned up the entry I had previously placed in the .bashrc file. So I ran a source ~/.bashrc command to refresh it. Still the same path. I then went back into the .bashrc file, set a new entry to set the UT_DATA_PATH to one of the other installs of the game. echo $UT_DATA_PATH then turned up the correct location for that install. Great, I thought, but the other server that has been running just fine, wouldn't start back up either. I started getting the same error on that server, as I was getting on the 3rd install I was creating.

My question is, where would my user be pulling that path location from, if the .bashrc file doesn't contain it an export command?

David the H. 06-21-2010 04:45 AM

Well, for one thing, removing an entry and re-sourcing bashrc alone will not unset any variables that are already set. Anything already there must be manually overwritten or unset, or the shell itself must be closed and restarted. It's unclear from the above if you did this.

Also, there are other start-up scripts besides bashrc. Check out the invocation section in your bash man page for which files are called when a shell starts. Finally, be aware that these scripts might also source other files as well. There can be a virtual maze of start-up scripts involved sometimes because of this.

unSpawn 06-21-2010 05:11 AM

As said previously if you don't log out and log back in then the environment value may still be set in the parent shell. If you have three different UT servers running then you may easily prep each with their own UT_DATA_PATH by either setting it in a per-server section of your script and exporting it like 'export UT_DATA_PATH=/usr/local/games/ut/1System' or using 'env' as in 'env UT_DATA_PATH=/usr/local/games/ut2/System /usr/local/games/ut2/System/ut-bin --your-args'.

Skillz 06-21-2010 10:09 AM

Restarting the terminal solved the problem! Thank you!


All times are GMT -5. The time now is 09:36 PM.