10-20-2000 01:42 AM
When i export a variable in a script, and try to use it from command prompt it does not seem to work.
ex:- in file a.sh
then try to do echo from prompt, the value is not set.
What should I do set the value.
10-20-2000 01:49 AM
this is normal behaviour.
export in a script is not 'back' exported.
When you start a script it executes in a sub shell that terminates on ending the script.
To have the variables in your own shell 'dot' the script:
then your script will not run in a subshell.
11-16-2000 01:18 PM
echo "Value" > valueFile
and then set the value from the command prompt by using command substitution,
var=$( cat valueFile )
11-16-2000 02:48 PM
11-16-2000 05:26 PM
This will treat the file like .profile and then you will retain the variables.
11-16-2000 05:28 PM
NOTE THE DOT
THis will treat the script as a .profile. THe variables should then take properly.
11-17-2000 02:33 AM
I don't think the execute bit even needs to be set when a file is sourced. The PATH variable will be referenced, however, if a path is not specified on the command line.