LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-19-2009, 03:49 PM   #1
alirezan1
Member
 
Registered: Nov 2004
Location: Vancouver
Distribution: Ubunty, CentOS ,Mandriva, Gentoo, RedHat, Fedora, Knoppix
Posts: 150

Rep: Reputation: 15
rc.local file question


Hi all,

I have a bash script that is supposed to export some global settings for my box and I want to put it in /etc/rc.d/rc.local file to get executed on system startup. Here's part of the bash script:

global.conf:
#!/bin/bash

export CTIME=190
export BBCODE=111
export TRUEFUNC=1
export FALSEFUNC=0
...

it goes on like this.

Also, at the end of the script, it calls another short script to set the foreground/background colors to white on black.

Okay, so far so good. I reboot the machine and it comes up fine and shows that I exported the global configuration file (I get it because it changes the default screen color from red on black to white on black). But, after a short while, the screen color goes back to its default, which is again red on black and when I log in, none of my variables are set.

Anyone has any ideas why this happens and how I can fix it?

Thanks
 
Old 01-19-2009, 03:58 PM   #2
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Try to run the script when the window manager starts.
 
Old 01-19-2009, 04:12 PM   #3
alirezan1
Member
 
Registered: Nov 2004
Location: Vancouver
Distribution: Ubunty, CentOS ,Mandriva, Gentoo, RedHat, Fedora, Knoppix
Posts: 150

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by repo View Post
Try to run the script when the window manager starts.
ah I forgot to mention, I don't use any window manager. It's all shell and no GUI.


Thanks
 
Old 01-19-2009, 04:18 PM   #4
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
.bashrc ?
 
Old 01-19-2009, 04:22 PM   #5
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,836
Blog Entries: 1

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
rc.local [edit: is executed] when you boot the system, so perhaps might overwrite the settings. Try to edit .bashrc which is executed everytime you log out/in.

Last edited by sycamorex; 01-19-2009 at 04:36 PM.
 
Old 01-19-2009, 04:30 PM   #6
alirezan1
Member
 
Registered: Nov 2004
Location: Vancouver
Distribution: Ubunty, CentOS ,Mandriva, Gentoo, RedHat, Fedora, Knoppix
Posts: 150

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by sycamorex View Post
rc.local when you boot the system, so perhaps might overwrite the settings. Try to edit .bashrc which is executed everytime you log out/in.
Thanks guys,

I have tried bashrc but a question here: should I always login for the bashrc to be executed or if I stop at the login prompt, it still works fine?

Thanks
 
Old 01-19-2009, 04:38 PM   #7
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,836
Blog Entries: 1

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
Quote:
Originally Posted by alirezan1 View Post
Thanks guys,

I have tried bashrc but a question here: should I always login for the bashrc to be executed or if I stop at the login prompt, it still works fine?

Thanks
I don't think so as .bashrc of a particular user is executed when they log in (and their default shell is bash).
 
Old 01-19-2009, 04:41 PM   #8
alirezan1
Member
 
Registered: Nov 2004
Location: Vancouver
Distribution: Ubunty, CentOS ,Mandriva, Gentoo, RedHat, Fedora, Knoppix
Posts: 150

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by sycamorex View Post
I don't think so as .bashrc of a particular user is executed when they log in (and their default shell is bash).
what about /etc/bashrc?

Thanks
 
Old 01-19-2009, 05:13 PM   #9
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,836
Blog Entries: 1

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
No, all those ~/.bashrc, /etc/bashrc, /etc/profile files specify users' shell settings so they refer to a situation when a user has logged in.
rc.local is the only file that comes to my mind that would do the job. What exactly did you add to rc.local?
 
Old 01-19-2009, 05:24 PM   #10
alirezan1
Member
 
Registered: Nov 2004
Location: Vancouver
Distribution: Ubunty, CentOS ,Mandriva, Gentoo, RedHat, Fedora, Knoppix
Posts: 150

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by sycamorex View Post
No, all those ~/.bashrc, /etc/bashrc, /etc/profile files specify users' shell settings so they refer to a situation when a user has logged in.
rc.local is the only file that comes to my mind that would do the job. What exactly did you add to rc.local?
I don't have much in my rc.local. I have two background processes that need to run on startup and that's about it. and I call my bash script like /etc/scripts/myscript

thanks
 
Old 01-20-2009, 01:45 PM   #11
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,836
Blog Entries: 1

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
To be honest I don't know why/when they get overwritten. Perhaps, you could post the contents of your script. Also, when exactly do they get overwritten? Is it always when you run some program or something?
 
Old 01-26-2009, 02:19 PM   #12
alirezan1
Member
 
Registered: Nov 2004
Location: Vancouver
Distribution: Ubunty, CentOS ,Mandriva, Gentoo, RedHat, Fedora, Knoppix
Posts: 150

Original Poster
Rep: Reputation: 15
I think what happens is, when the bash script is called from within another bash script (like rc.local), it is executed in a separate session and therefore the variables are not set in the same session which explains why I can't see the env variables.

Any workaround guys?

Thanks
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
source code file 'Not a local file' error with anjuta 2.4.2 PrathuD Linux - Newbie 2 10-24-2008 10:36 AM
rc.local question harkonen Slackware 10 07-12-2007 11:55 AM
Small question about /etc/rc.local - Symbolic link question Arodef Linux - General 4 05-13-2006 02:29 AM
local rc file? Rnastyracer Linux - Software 2 04-01-2004 12:58 AM
rc.local question BoldKiller Linux - General 1 12-11-2002 08:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration