3

I'm trying to make a system call from a python code to the Boxer text parser program and I find that the following set of statements doesn't work. It doesn't give me any error but I don't see any output file created. When I run the same command on the terminal, the output file does get created.

from subprocess import call
candcStr = 'echo "Every Man Walks" | /home/candc-1.00/bin/candc --models /home/candc-1.00/models/boxer --output /tmp/test.ccg' 
args = shlex.split(candcStr)
call(args)

When I run the above code, the console shows

Every Man Walks | /home/candc-1.00/bin/candc --models /home/candc-1.00/models/boxer --output /tmp/test.ccg

It appears as though the pipe redirection isn't working. Does anyone know how I can fix this ? Thanks!

1

1 Answer 1

4

You need to set shell=True for the shell to interpret the command, and most of all the pipe:

call(args, shell=True)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.