Added shell=true in popen to allow shell commands
Exit system command on failure
Redirect errors to stdout so server will receive them