pythonoperating-systemsystem

Handling executed system command errors in Python


There is system() function from os library, however it can't handle errors. I know it returns error codes ( For example, when command is executed successfully, it returns 0. ) but it doesn't throws any exceptions so I can't handle these errors with try-except keyword. Is there a function that throws error that can handled with try-except?

It would be better if that function is in a built-in library like os or sys.


Solution

  • So I did some testing, and I couldn't figure it out either. So I Googled your question and found this link, which should answer your question. If it doesn't help, I don't know of any other possible fixes to your problem.