Did you know LQ has a Linux Hardware Compatibility List?
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This 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.


LinkBack Search this Thread
Old 01-15-2004, 03:44 PM   #1
Registered: Aug 2003
Posts: 132

Rep: Reputation: 15
Environment Variables in Scripts

I'm trying to add two new variables with assigned values to my environment. I've tired the syntax a number of different ways and no results. Please see below:

JHHOME = /usr/java/OnlineHelp
JAVAHELP_HOME = /usr/java/OnlineHelp

JHHOME = "/usr/java/OnlineHelp"
JAVAHELP_HOME = "/usr/java/OnlineHelp"

If I key them in via a terminal window they work fine. Whe placed in a script the result are null. What I'm i missing here?

I also perform an echo $JHHOME and $JAVAHELP_HOME and results are null. Am I missing something simple here?

What shoud they look like in a script file. I am sourcing the script file correctly correctly as ". ./usr/scripts/java_paths". I have other scripts in this file and they are working fine.


Old 01-15-2004, 03:46 PM   #2
Registered: Jan 2004
Posts: 33

Rep: Reputation: 15
What shell?

options gravitate from setenv var value to export var=value to set var=value to... depending on what you want to accomplish.

Old 01-15-2004, 03:51 PM   #3
Registered: Jul 2003
Location: Göteborg
Distribution: Arch Linux (current)
Posts: 553

Rep: Reputation: 30
What your missing is to export the variables. If you're using bash (which it seems like, since you use equality signs) then you have to put export in front of every variable that you want to become an environment variable. Like this:

export JHHOME=/usr/java/OnlineHelp
export JAVAHELP_HOME=/usr/java/OnlineHelp
Another way is to just do


I've also removed the spaces around the equality signs; I think there mustn't be any.

In tcsh, you use setenv instead of export, as well as no =.
Old 01-15-2004, 04:56 PM   #4
Registered: Aug 2003
Posts: 132

Original Poster
Rep: Reputation: 15
Thanks it worked Great.



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 On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Scripts & Environment Variables geeman2.0 Linux - General 12 07-05-2005 05:10 PM
environment variables user_linux Linux - Newbie 3 06-15-2005 08:46 AM
Why can't my scripts set environment variables? Matthew3 Linux - Software 5 08-28-2004 05:26 PM
Need help setting right environment variables:configure scripts can't find libraries. z-vet Linux - Newbie 4 08-16-2004 05:10 PM
environment variables moeminhtun Linux - General 4 01-15-2003 09:50 AM

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

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