I'm trying to make a simple if-check in python. I check for a certain hostname and set path accordingly.
But the result is unexplainable to me.
hostname = os.system('hostname')
if(hostname == 'rkim'):
path = '/home/forge/rkim-web-app/'
# This block of code should be running
else:
path = '/Applications/MAMP/htdocs/code/rkim-web-app/'
# But this block of code run instead
Result :
python /home/forge/rkim-web-app/database/backup_mysql.py
rkim <-------- hostname printed == rkim
Traceback (most recent call last):
File "/home/forge/rkim-web-app/database/backup_mysql.py", line 28, in <module>
file = open(path + '.env', "r")
IOError: [Errno 2] No such file or directory: '/Applications/MAMP/htdocs/code/rkim-web-app/.env'
What did I do wrong ?