0

I am running a Python script that calls another program that takes in input files and converts it to another format.

I have

subprocess.check_output("/usr/local/bin/program -c convert -f {0} -o {1}".format(full_input_path, full_output_path),shell=True).split("\n")[0:-1]

I get the error Command '/usr/local/bin/program -c convert -f /full/path/to/input/file -o /full/path/to/output/folder' returned non-zero exit status 1

However, if I copy and paste the exact command in the error message and run it on its own, there is no error. Even when I run the script with the error message, the input file is still correctly converted and stored in the output folder. It all seems like there is nothing wrong with the command.

I'm suspect that the program code simply exits with status 1 even where there is no error, but I can't check because I don't have the source code.

Is there a way to not display the error message?

Rayne
  • 14,247
  • 16
  • 42
  • 59
  • 1
    You can print the exit code of the program after termination like this: `echo $?` – moooeeeep Apr 13 '18 at 09:39
  • Um... bash variable `?` stores the last return code. So `echo $?` will give you what you want. – Sraw Apr 13 '18 at 09:41
  • 2
    Possible duplicate of [python subprocess check\_output returned non-zero exit status 1](https://stackoverflow.com/questions/27920837/python-subprocess-check-output-returned-non-zero-exit-status-1) – moooeeeep Apr 13 '18 at 09:43

0 Answers0