My problem is that my script cannot access variables that are stored in
~/.bashrc.
Here is (part of) my local .bashrc file:
$ cat ~/.bashrc
myvar="abc"
And here is my small script:
$ cat myscript.sh
#!/bin/bash
echo "$myvar"
The $myvar is loaded correctly:
$ echo $myvar
abc
But the script is unable to display it...
$./myscript.sh
$
For some reason nothing is displayed when I execute myscript.sh. Is
there a solution for this problem?
Ramon.
export myvar="abc"
instead
...
> For some reason nothing is displayed when I execute myscript.sh.
myvar is [a] local [variable] to the running bash and not part of its
environment variables which are "exported" to any new program.
> Is
> there a solution for this problem?
See above.
That is a local variable, you need to export the variable to other processes-
export myvar="abc"
Test your script after that.
--
//Aho
Thx lads, it worked great.
http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html may prove useful for
you.
--
Jon Solberg (remove "nospam." from email address).