Results 1 to 6 of 6
Hi All,
i written a small shell script the usese export command... but when i execute that script, my shell will exit???
Please find the code
temp.sh
echo the value ...
- 08-11-2008 #1Just Joined!
- Join Date
- Aug 2008
- Posts
- 49
How to use export in shell???
Hi All,
i written a small shell script the usese export command... but when i execute that script, my shell will exit???
Please find the code
temp.sh
echo the value exported by the shell is $var
var=newvalue
export var
#exec otherfilepathname
exec /home/abc.sh
abc.sh contains
echo "the value of $var"
when i execute temp.sh, my shell terminal will exit....
- 08-11-2008 #2Linux Newbie
- Join Date
- Jul 2008
- Posts
- 181
Don't use exec. Use "." or "sh" instead.
- 08-12-2008 #3Just Joined!
- Join Date
- Aug 2008
- Posts
- 49
Why not exec, what is the problem in using exec???
Hey hi,
I used .(dot), instead exec its working now... but what is the problem with exec???
- 08-12-2008 #4Linux Newbie
- Join Date
- Jul 2008
- Posts
- 181
"Exec" replaces the current shell with another program. It does not return.
- 08-12-2008 #5Just Joined!
- Join Date
- Aug 2008
- Posts
- 49
Cool man... but once its exit the terminal. i reopened the new terminal, but at that time i am not able to print that variable, which i jave exported...what is reason for that??? do need to put it in .bashrc???
- 08-12-2008 #6Linux Newbie
- Join Date
- Jul 2008
- Posts
- 181
The export statement only affects the current session. If you want to have the variable available in all your sessions, you need to put the export statement in an init file, such as ".bashrc".


Reply With Quote