In my /etc/bash.bashrc file, I have following:
export SYNCTOOL=/root/Desktop/gb
alias synctest='python $SYNCTOOL/App.py'
In App.py:
from xml.dom.minidom import parse
XML = parse('$SYNCTOOL/Data/Config.xml')
When I type “synctest” in my shell, I’m getting the error below:
root@bt:~# synctest
Traceback (most recent call last):
File "/root/Desktop/gb/App.py", line 12, in <module>
XML = parse('$SYNCTOOL/Data/Config.xml')
File "/usr/lib/python2.6/xml/dom/minidom.py", line 1918, in parse
return expatbuilder.parse(file)
File "/usr/lib/python2.6/xml/dom/expatbuilder.py", line 922, in parse
fp = open(file, 'rb')
IOError: [Errno 2] No such file or directory: '$SYNCTOOL/Data/Config.xml'
When I look for the file with “cat” command:
root@bt:~# cat $SYNCTOOL/Data/Config.xml
<?xml version="1.0" ?>
<AllConfigurations>
<!-- PROGRAM OPTIONS START -->
..
...
So, I’m really confused. What should I do?
Bash variable are not automatically expanded, use
os.environto access them: