There is only one way to check for errors in any programming language. You need to test the return values of the functions that you call.
Most functions return zero or false when something goes wrong.
In a numeric context it holds the current value of errno . If used in a string context, it holds the error string associated with errno . The variable, errno , is pre-defined variable that can sometimes be used to determine the last error that took place. My recommendation is to capture the output of the back-quoted string and check it directly for error messages. Once you detect an error and you can't correct the problem without outside intervention, you need to communicate the problem to the user.