If there is an error, I want to show this error to the messagebox and stop the if statement.
how can I catch the error guys?
If there is an error, I want to show this error to the messagebox and stop the if statement.
how can I catch the error guys?
Depends on how your calling it. If your using the subprocess module :
p = subprocess.Popen(['chown', 'bad_user', '/file_path'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
print(err)
should give you:
chown: bad_user: illegal user name
Now this is in Python 2.7. Python 3 has an easier way of calling it. Should be: (Not tested)
result = subprocess.run(['chown', 'bad_user', '/file_path'], stdout=subprocess.PIPE)
result.stdout