So I am still teaching myself Python and I wanted to created a small script for my server that will tell me if my HDD is mounted and if not to mount it for me when I sign in. (I have it in ~/.bashrc).
The problem I am facing is this:
try:
with open('/media/Hitachi/mountfile.txt', 'r') as f:
print(f.readline())
except:
print('HDD is not mounted')
if not os.path.exists('/media/Hitachi/media'):
print('Attempting to mount HDD')
script = subprocess.call('mountscript.sh', shell=True)
How can I find out if mountscript.sh succeeded or not?