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?

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')

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.