0

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

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.