importing variables into shell script?
Perhaps the title is incorrect, but here is the situation: in ~/.profile, I define value for variable foo. I am writing a script which needs the value of foo:
Code:
#!/bin/sh Code:
$ echo $foo Any pointers would be appreciated. |
Different distributions use different files for shell initialization. Try .bashrc or .bashrc_profile. What distribution are you using?
--------------- Steve Stites |
Quote:
|
Environment variables are exportable, and are typically in all CAPS:
Code:
$ FOO='some value' |
If I recall correctly, .profile is only read by the login shell. Therefore, if foo is defined in .profile, but not exported, it will not be inherited by a subshell.
|
Actually, ocicat, if you're used to the ksh, then specify that at the top of your script, not /bin/sh.
Also, as mentioned above, vars are not exported by default, you have to specify it as described by Mr C. |
All times are GMT -5. The time now is 10:09 AM. |