The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Setting up variables solar_ext UNIX for Dummies Questions & Answers 3 03-28-2008 08:50 AM
Setting numbered variables michaeltravisuk UNIX for Dummies Questions & Answers 1 10-28-2007 05:35 AM
Setting variables in a function BCarlson Shell Programming and Scripting 1 03-29-2006 08:15 AM
cat setting variables skotapal Shell Programming and Scripting 3 09-10-2002 06:55 AM
Setting up shell variables rachael UNIX for Dummies Questions & Answers 1 10-21-2001 08:16 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 03-13-2008
Registered User
 

Join Date: Jan 2006
Posts: 126
setting some variables

i have a file .NAME
Code:
export MY_NAME=JOE
when i do this at the command prompt
Code:
#. .NAME
$echo MY_NAME
$JOE
i created a script called Run.sh
Code:
 . .NAME
At the command prompt i did
Code:
#sh Run.sh
#echo $MY_NAME
it returns nothing. What have i missed out?
Reply With Quote
Forum Sponsor
  #2  
Old 03-13-2008
Registered User
 

Join Date: Mar 2008
Location: /bin/sh
Posts: 352
If you want the variable to be displayed when you run "RUN.sh" , you need to source the "RUN.sh" script also.

mv run.sh .run.sh

sh .run.sh

and it would do the needful.
Reply With Quote
  #3  
Old 03-13-2008
Registered User
 

Join Date: Jan 2006
Posts: 126
Hi nua7,

i tried your suggestion, its still not working.
Reply With Quote
  #4  
Old 03-13-2008
Registered User
 

Join Date: Mar 2008
Location: /bin/sh
Posts: 352
Which shell are you using? Really shouldn't make a difference since this is common for all the shells.

I tried doing it and it is succesful in displaying the variable MY_NAME.

Can you show me your steps with the output..?
Reply With Quote
  #5  
Old 03-13-2008
Registered User
 

Join Date: Jun 2006
Posts: 74
Hi new2ss,

I believe that u wont get the output if u run

sh Run.sh or sh .run.sh

as the new variable will be set only in the shell created for Run.sh and the shell wud terminate once the execution of run.sh is over

so, if u want to achieve the result then u shld run like

. Run.sh or . .run.sh
Reply With Quote
  #6  
Old 03-13-2008
Registered User
 

Join Date: Jan 2006
Posts: 126
Hi, i am using bash shell.

the output was exactly the same as what i posted earlier.
Reply With Quote
  #7  
Old 03-13-2008
Registered User
 

Join Date: Jan 2006
Posts: 126
Hi quintet,

your suggestion worked. Thanks. Because i need to set it as a cronjob,
would typeing . run.sh at the crontab entry work?
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:08 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0