Help on setting path variable


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Help on setting path variable
# 1  
Old 11-15-2006
Help on setting path variable

Hi there,

I need help on setting the path variable. How can I set the path variable with Bourne Shell. My scripts goes like this, but did not work.

#!/bin/sh

PATH=/usr/bin:/usr/ucb:/etc:/export/home/zchen/home
export PATH

Thanks,
Z
# 2  
Old 11-15-2006
You have the correct syntax. What is the problem you are experiencing?
# 3  
Old 11-15-2006
How did you invoke the script ?

Try this
Code:
. myscript.sh

or just source it.
Code:
source myscript.sh

# 4  
Old 11-15-2006
when i invoke the script by using interactive command, i.e.

set path=($path /export/home/zchen/home)

it works fine, but when i invoke by sh myscript.sh, it does not work.

any idea?
# 5  
Old 11-15-2006
Like vino said, if you want the PATH to affect your current shell, you need to source the script. Look at his post again.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Problem setting path to external hard drive as a variable

Hello all, I am EXTREMELY new to using bash and I have a bit of a problem: I'm trying to set up a shell script that can 1.) take one of several giant files off of an external hard drive 2.) use it as input for scripts on my laptop's hard drive ... (3 Replies)
Discussion started by: machine_spirit
3 Replies

2. Shell Programming and Scripting

Understanding PATH variable setting?

I do know how we set the PATH variable- export PATH=$JAVA_HOME/bin:$PATH I'm trying to understand why we have written :$PATH in the end above statement. What is it's meaning? (2 Replies)
Discussion started by: boy18nj
2 Replies

3. Shell Programming and Scripting

Setting path variable with a space.

Hi I am using MKS Toolkit c shell. I am trying to set a path variable something like c:/Program Files/blah/blah so set path=(c:/Program Files/blah/blah) this, however, does not work as it splits this thing up into 'c:/Program' and 'Files/blah/blah'. Does anyone have any ideas on... (9 Replies)
Discussion started by: vas28r13
9 Replies

4. Shell Programming and Scripting

Path a variable to sed that includes a path

Hi I'm trying to select text between two lines, I'm using sed to to this, but I need to pass variables to it. For example start="BEGIN /home/mavkoup/data" end="END" sed -n -e '/${start}/,/${end}/g' doesn't work. I've tried double quotes as well. I think there's a problem with the / in the... (4 Replies)
Discussion started by: mavkoup
4 Replies

5. Shell Programming and Scripting

Appending a path in user's PATH variable

Hello Folks, I want to append a path in user's PATH variable which should be available in current session. Background Numerous persons will run a utility. Aim is to add the absolute path of the utility the first time it runs so that next runs have the PATH in env & users can directly run... (6 Replies)
Discussion started by: vibhor_agarwali
6 Replies

6. Shell Programming and Scripting

one liner to extract path from PATH variable

Hi, Could anyone help me in writing a single line code by either using (sed, awk, perl or whatever) to extract a specific path from the PATH environment variable? for eg: suppose the PATH is being set as follows PATH=/usr/bin/:/usr/local/bin:/bin:/usr/sbin:/usr/bin/java:/usr/bin/perl3.4 ... (2 Replies)
Discussion started by: royalibrahim
2 Replies

7. Shell Programming and Scripting

remove a path from PATH environment variable

Hi I need a script which will remove a path from PATH environment variable. For example $echo PATH /usr/local/bin:/usr/bin:test/rmve:/usr/games $echo rmv test/rmve Here I need a shell script which will remove rmv path (test/rmve) from PATH... (9 Replies)
Discussion started by: madhu84
9 Replies

8. Shell Programming and Scripting

Error in setting PATH variable in bash shell

Hi, I am new to shell scripting.I tried adding an entry to the path variable like below export PATH=$PATH:/opt/xxx/bin But am getting an error invalid identifier /opt/xxx/bin Can someone tell me the error above and correct me . Thanks and Regards, Padmini (2 Replies)
Discussion started by: padmisri
2 Replies

9. Shell Programming and Scripting

Setting path

Hi all, I have a java command in a shell script. When i m executing the command from the prompt its working fine. But when i paste the same command in a shell script and execute the shell script it says path not found. Please help. (5 Replies)
Discussion started by: radhika03
5 Replies
Login or Register to Ask a Question