There is a $CONFIG variable which stores the way to some dir on unix. I created following python script to test path variable in unix.
import os
path=os.environ.get('$CONFIG')
if os.path.exists(path) is True:
print '{} path exists'.format(path)
else:
print 'problem'
It gives me an error message:
Traceback (most recent call last):
File "test.py", line 6, in <module>
if os.path.exists(path) is True:
File "/usr/lib64/python2.7/genericpath.py", line 18, in exists
os.stat(path)
Woul you please help me how to correctly define path to unix folder using a variable in python script?
asked Apr 8, 2019 at 12:45
JanFi86
5291 gold badge14 silver badges35 bronze badges
1 Answer 1
Remove the $ from the variable and it may work. ($ is used in linux terminal, not in python):
path=os.environ.get('CONFIG')
answered Apr 8, 2019 at 13:12
samthegolden
1,5181 gold badge12 silver badges30 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-py