problem in getting the path of environment variable set in bashrc in my shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting problem in getting the path of environment variable set in bashrc in my shell script
# 1  
Old 05-24-2006
problem in getting the path of variable set in bashrc in my shell script

hi all

i have joined new to the group.

i have set an variable in my bashrc file.
.bashrc
PROGHOME=/home/braf/braf/prog
export PROGHOME


but while using it in my shell script its path is not taken and i had to explicitly give the export command to set the path.

in my script file
PROGHOME=/home/braf/braf/prog
export PROGHOME

if i give export the script is executing and taking the file from correct path but not directly from bashrc.

can anyone help me over this plz

Last edited by krithika; 05-24-2006 at 09:10 AM..
# 2  
Old 05-24-2006
I think you are executing the script by correct user.

If you have set varibale in your .bashrc file and then are you running the script under the same profile?

because evry time one logg's in .bashrc gets executed if not then it will not..
# 3  
Old 05-24-2006
thanks nilesrex

but i am runing the script in the same user and in the same shell.
in the shell promt when i do echo , i get the correct path.
only the script i dont get it.

i hope i have understood ur question properly and replied.
# 4  
Old 05-24-2006
You have to check your login shell, is it really bash? type command echo $SHELL to find out your login shell and then modify appropriate login file as per your shell.
# 5  
Old 05-24-2006
i checked its also correct
/bin/bash is what i had used in my script file also
# 6  
Old 05-24-2006
Once you logged in to your login you can do echo $PROGRAM,

and check if this variable is getting set correctly if it is not that means ur .bashrc is not getting executed..
# 7  
Old 05-25-2006
after loged in my user and if i give echo $PROGHOME it gives
/home/braf/braf/prog ie its giving the correct path...
but only inside the script its not getting the path properly and i had to do export again to get the correct path
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Ubuntu

PATH environment variable

PATH is an environment variable. When I open a terminal say terminal 1 and set some path in PATH variable it gets set which I can see using ech $PATH. But when I open a new terminal say terminal 2 and fire echo $PATH why cannot I see the same output as seen in terminal terminal 1? Why the path... (4 Replies)
Discussion started by: rupeshkp728
4 Replies

2. Shell Programming and Scripting

environment variable in shell script called through crontab

Please help me on below.. https://www.unix.com/shell-programming-scripting/141533-retrieve-value-environment-variable-shell-script-called-crontab.html#post302442024 I'm still here. I can still see you! (0 Replies)
Discussion started by: jadoo_c2
0 Replies

3. Shell Programming and Scripting

Setting environment variable using shell script

Hi All, I'm trying to write an menu driven program to automate some functions which involve loging to multiple hosts. The hosts can differ for every use, so I thought I would use an config file to get the hostnames. Now I need to set those values in the config file to environment variable to... (6 Replies)
Discussion started by: arun_maffy
6 Replies

4. 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

5. Shell Programming and Scripting

How to set PATH using shell script [resolved]

Hi, Can anyone help me on how to set PATH using shell scripting.. Please find the shell script code here.... #!/bin/bash PATH = $PATH:/opt/app/oracle/product/10.2.0/bin export PATH echo $PATH exit When i execute this script i get the following error ./backup.sh: line 2: PATH:... (0 Replies)
Discussion started by: srinivasj
0 Replies

6. Solaris

set environment variable?

I am working with solaris 9 sunBlade150 Box. I Installed a program, need to set the environment variable so that when the executable is entered,it finds the path to the executable. The documentation for the software says: Set the appropriate environment variable: Connect to server failed;... (8 Replies)
Discussion started by: smartgupta
8 Replies

7. Shell Programming and Scripting

:: in PATH environment variable

whats the meaning of :: colon in PATH environment? /usr/local/bin:/usr/bin:/usr/local/gnu/bin::.:/usr/local/bin:/usr/bin:/usr/local/gnu/bin:/usr/local/bin and whats the meaning of // in PATH ? (1 Reply)
Discussion started by: gfhgfnhhn
1 Replies

8. Shell Programming and Scripting

Path Environment Variable

Hi..... I'm kind of new to c programming in Unix...need help here. Supposed to write a source code to support Path environment variable for my programming assignment for Spring semester. but i'm kind of stuck. Could anyone out there assist me? prompt> /bin/ls My program could output... (3 Replies)
Discussion started by: tancy
3 Replies

9. UNIX for Advanced & Expert Users

How does the PATH and MANPATH environment variable get set?

Hi, How does the PATH and MANPATH environment variable get set? I want to add "/opt/SUNWspro/bin" to the search path for all the users. Where can I access this variable. I know in my home directory, depend on which shell I use, there are files such as .profile and .cshrc which I can edit to... (3 Replies)
Discussion started by: vtran4270
3 Replies

10. Shell Programming and Scripting

Set Path variable in c shell

I set my path environment variable in c shell, using the syntax below setenv PATH "${PATH}:/usr/local:/usr/local/bin" and placed this in $HOME/.login $HOME/.cshrc and /etc/.login /etc/.cshrc but when I issued echo $PATH or set command the output does not reflect changes made to... (5 Replies)
Discussion started by: hassan2
5 Replies
Login or Register to Ask a Question