LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-28-2004, 03:12 PM   #1
Matthew3
LQ Newbie
 
Registered: Aug 2004
Location: Rochester, NY
Distribution: Fedora Core 2 at the moment
Posts: 3

Rep: Reputation: 0
Why can't my scripts set environment variables?


Greetings. This is my first post on this forum. I am trying to make my computer set some environment variables as follows (the exact variables aren't really important for this question):

CPPFLAGS='-I/opt/glibmm/include -I/opt/gtk/include -I/opt/gtkmm/include -I/opt/libsigc++/include -I/opt/xine-lib/include $CPPFLAGS'
LDFLAGS='-L/opt/glibmm/lib -L/opt/gtk/lib -L/opt/gtkmm/lib -L/opt/libsigc++/lib -L/opt/xine-lib/lib $LDFLAGS'
PKG_CONFIG_PATH='/opt/glibmm/lib/pkgconfig:/opt/gtk/lib/pkgconfig:/opt/gtkmm/lib/pkgconfig:/opt/libsigc++/lib/pkgconfig:/opt/xine-lib/lib/pkgconfig:$PKG_CONFIG_PATH'
LD_LIBRARY_PATH='/opt/glibmm/lib:/opt/gtk/lib:/opt/gtkmm/lib:/opt/libsigc++/lib:/opt/xine-lib/lib:$LD_LIBRARY_PATH'
PATH='/opt/gtk/bin:/opt/xine-lib/bin:/opt/xine-ui/bin:$PATH'
export CPPFLAGS LDFLAGS PKG_CONFIG_PATH LD_LIBRARY_PATH PATH

If I paste these lines into the shell, they work for that instance of the shell. When I restart the shell, I must repaste them. If I put them in ~/.bash_profile, they have no effect. If I put them into a file and run that file, it has no effect whatsoever. What am I doing wrong?

I'm using Fedora Core 2 if that makes any difference.

Thanks in advance!
 
Old 08-28-2004, 03:16 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Welcome to LQ.

They will only last for the duration of that script. You will need to source the script into your shell using iether of:
source /path/to/script
. /path/to/script
 
Old 08-28-2004, 03:45 PM   #3
Matthew3
LQ Newbie
 
Registered: Aug 2004
Location: Rochester, NY
Distribution: Fedora Core 2 at the moment
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks! That made the script commands work as I wanted (I also had to change my apostrophes to quotes). What is the best way to make the script run every time I open the console if I only want it to apply to my account?
 
Old 08-28-2004, 04:20 PM   #4
rhorn
LQ Newbie
 
Registered: Aug 2004
Location: Wisconsin, US
Distribution: Debian
Posts: 7

Rep: Reputation: 0
Try putting them in your ~/.bashrc script instead.
 
Old 08-28-2004, 04:24 PM   #5
mikshaw
LQ Addict
 
Registered: Dec 2003
Location: Maine, USA
Distribution: Slackware/SuSE/DSL
Posts: 1,320

Rep: Reputation: 45
If you put them in ~/.bash_profile they'll take effect the next time you log in. bash_profile is a good way to set variables to be available from any shell.
bashrc will only set variables for non-login shells, unless you have "source $HOME/.bashrc" in ~/.bash_profile

Last edited by mikshaw; 08-28-2004 at 04:27 PM.
 
Old 08-28-2004, 05:26 PM   #6
Matthew3
LQ Newbie
 
Registered: Aug 2004
Location: Rochester, NY
Distribution: Fedora Core 2 at the moment
Posts: 3

Original Poster
Rep: Reputation: 0
Putting it in ~/.bashrc worked. Thanks!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Scripts & Environment Variables geeman2.0 Linux - General 12 07-05-2005 05:10 PM
Need help setting right environment variables:configure scripts can't find libraries. z-vet Linux - Newbie 4 08-16-2004 05:10 PM
How to set environment variables anjaan Linux - General 3 06-10-2004 02:04 PM
Help with the currently set environment variables!! apoc013 Linux - Newbie 6 01-21-2004 01:28 AM
Environment Variables in Scripts louisb Linux - General 3 01-15-2004 04:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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

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