LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 11-02-2009, 02:39 AM   #1
elainelaw
Member
 
Registered: Jan 2008
Posts: 258

Rep: Reputation: 30
How to set the variable


I use the below command on the shell can set the variable , it works .

$export ORA=/opt/ora
echo $ORA
/opt/ora

$export JAVAHOME=/usr/java
echo $JAVAHOME
/usr/java

but if I add these two lines to a file , and then run it , it do not work .

can advise I have many varibles that want to be added to my current login , except run it one by one , what can i do ? thx
 
Old 11-02-2009, 02:55 AM   #2
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 704

Rep: Reputation: 55
Hi elainelaw

open /etc/bashrc file and add

Code:
$export ORA=/opt/ora
$export JAVAHOME=/usr/java
execute

Code:
source /etc/bashrc
Hope this helps.....
Cheers !!!
 
Old 11-02-2009, 03:21 AM   #3
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Distribution: UBUNTU 5.10 since Jul-18,2006 on Intel 820 DC
Posts: 813

Rep: Reputation: 195Reputation: 195
You know,I googled and THIS was th first result.

http://www.linuxquestions.org/questi...script-344057/

End
 
Old 11-02-2009, 03:45 AM   #4
elainelaw
Member
 
Registered: Jan 2008
Posts: 258

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by vinaytp View Post
Hi elainelaw

open /etc/bashrc file and add

Code:
$export ORA=/opt/ora
$export JAVAHOME=/usr/java
execute

Code:
source /etc/bashrc
Hope this helps.....
Cheers !!!

thx reply,

But if I don't to change anything in system , I only use it to test , I will use it for one time only , can advise is there other method ? thx
 
Old 11-02-2009, 06:03 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Quote:
Originally Posted by elainelaw View Post
I use the below command on the shell can set the variable , it works .

$export ORA=/opt/ora
echo $ORA
/opt/ora

$export JAVAHOME=/usr/java
echo $JAVAHOME
/usr/java

but if I add these two lines to a file , and then run it , it do not work .

can advise I have many varibles that want to be added to my current login , except run it one by one , what can i do ? thx
Source the file rather than run it. When you run it it does work -- for the process the script is running in and any of its children; when that process ends the changes are lost; you want to make the change in your current shell; when you source the script its commands are run in your current shell exactly as if you typed them.
 
  


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
How to set Variable Isuru Divarathne Linux - Software 2 10-14-2009 09:42 AM
how to set a variable in a script and have the variable still set after script termin john test Linux - Newbie 9 10-21-2008 06:21 PM
how to set environment variable pranith Linux - Newbie 1 01-28-2005 12:23 AM
Set variable with value of another Ephracis Programming 7 12-25-2004 11:34 AM
set DISPLAY variable W1pEout[64] Linux - Software 4 01-07-2004 10:41 AM


All times are GMT -5. The time now is 09:17 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration