I basically want to set path for some of the variables in Unix. But the source command does not work here. Any suggestions of the same?
I tried what you describe and the solution is to use
. instead of
source, which is basically an alias of the former.
You also must explicitly specify
./FILENAME if the file in the current directory.
Please see my example session:
Python 2.7.10 (default, Oct 14 2015, 16:09:02) [GCC 5.2.1 20151010] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.system("source .bashrc") sh: 1: source: not found 32512 >>> os.system(". .bash_aliases") sh: 1: .: .bash_aliases: not found 512 >>> os.system(". ./.bash_aliases") 0 >>> os.system(". ~/.bash_aliases") 0 >>> os.system(". /home/USERNAME/.bash_aliases") 0
A return value of
0 indicates success.
However, I am not sure if sourcing a file this way produces the results you want, as this method runs the given command in a subshell and I am not sure if this also affects the shell session you want.