setting some variables


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users setting some variables
# 1  
Old 03-13-2008
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?
# 2  
Old 03-13-2008
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.
# 3  
Old 03-13-2008
Hi nua7,

i tried your suggestion, its still not working.
# 4  
Old 03-13-2008
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..?
# 5  
Old 03-13-2008
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
# 6  
Old 03-13-2008
Hi, i am using bash shell.

the output was exactly the same as what i posted earlier.
# 7  
Old 03-13-2008
Hi quintet,

your suggestion worked. Thanks. Because i need to set it as a cronjob,
would typeing . run.sh at the crontab entry work?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Setting variables in UNIX

Hi, I am a beginner in Unix. Now I am learning setting up variables. However, I am receiving an error. Can anyone please help me with it My command as Test=unixprogramming returns the error command not found. (I am using FreeBSD Unix and in my terminal, it is ~% instead of $ . is the... (2 Replies)
Discussion started by: kgopan
2 Replies

2. UNIX for Dummies Questions & Answers

Setting up environment variables

Hi all, This is my first post here. I need to set up a few environment variables with a shell script. Some are hard-coded, but some should come from other commands or as input from the user. How do I do that? For example, I need to export a variable as such: export DISPLAY=127.0.0.1:8.0 ... (2 Replies)
Discussion started by: exchequer598
2 Replies

3. UNIX for Dummies Questions & Answers

Setting Environment Variables

#!/bin/bash if ; then ASS1_DATA_DIR=./ echo $ASS1_DATA_DIR export ASS1_DATA_DIR echo "data dir" fi if ; then ASS1_OUTPUT_DIR=./ export ASS1_OUTPUT_DIR fi I want to create a new environment variable ASS1_DATA_DIR and ASS1_OUTPUT_DIR in bash and set them to the current... (4 Replies)
Discussion started by: bigubosu
4 Replies

4. UNIX for Dummies Questions & Answers

Need help with setting up environment variables

hi all, I would appreciate if some one could explain me the difference between setting up the variables as shown below HOME=${HOME:-"/home/user1"} HOME=/home/user1 (1 Reply)
Discussion started by: SSSB
1 Replies

5. UNIX for Dummies Questions & Answers

setting enviroment variables help

Hello everyone, I am currently trying to program in java in unix platform for the first time, so far it is OK as long as I use class libraries which come with java distribution. Unfortunately when I try to use external libraries I have to use -classpath option which I rather not doing all the... (1 Reply)
Discussion started by: run123
1 Replies

6. UNIX for Dummies Questions & Answers

Setting up variables

Hi all, I have a shell script that sets up the environment for an application running on UNIX - ksh. This script is run using: . ./script_name XX where XX is a parameter. I want to run it from another shell script but when I do it I don't get the envornment variables set up and the prompt... (3 Replies)
Discussion started by: solar_ext
3 Replies

7. Shell Programming and Scripting

Setting up Environment Variables

Hi all, I am trying to set up some variables in a shell script. The variables contain values of various paths needed to run a java module. The problem is the variables dont seem to be setting at all. here is what i am trying to do : JAR_HOME=/home/was5/bdcms/scheduledjobs/lib export... (6 Replies)
Discussion started by: rpandey
6 Replies

8. AIX

Setting Variables not working

Hi all, I am trying to set up some variables in a shell script. The variables contain values of various paths needed to run a java module. The problem is the variables dont seem to be setting at all. here is what i am trying to do : JAR_HOME=/home/was5/bdcms/scheduledjobs/lib export... (1 Reply)
Discussion started by: rpandey
1 Replies

9. Shell Programming and Scripting

cat setting variables

hi All I have a file that has 4 lines: 1. yesterday's date (mm/dd/yyyy) 2. yesterday's day- dd 3. yesterday's month- mm 4. yesterday's year- yyyy I want to read this file and place them in variables. how can I do this. Please help. thanks in advance!! KS (3 Replies)
Discussion started by: skotapal
3 Replies

10. UNIX for Dummies Questions & Answers

setting environment variables ???

Hello, I want to set some environment variables with this script: ip=$@ echo Remote Computer: $ip PERLDB_OPTS="CallKomodo=$ip:9000 RemotePort=$ip:9010 PrintRet=0" export PERLDB_OPTS PERL5LIB=/opt/komodo export PERL5LIB echo PERLDB_OPTS: $PERLDB_OPTS echo PERL5LIB: $PERL5LIB But it... (5 Replies)
Discussion started by: Gargamel
5 Replies
Login or Register to Ask a Question