LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 11-02-2009, 01: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, 01:55 AM   #2
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 707

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, 02:21 AM   #3
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Posts: 952

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

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

End
 
Old 11-02-2009, 02: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, 05:03 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
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



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 08: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 05:21 PM
how to set environment variable pranith Linux - Newbie 1 01-27-2005 11:23 PM
Set variable with value of another Ephracis Programming 7 12-25-2004 10:34 AM
set DISPLAY variable W1pEout[64] Linux - Software 4 01-07-2004 09:41 AM

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

All times are GMT -5. The time now is 02:09 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