I have a python script that generates several shell commands from a given input. The problem is that when he tries to execute the generated commands, it fails, but when I run the generated commands myself (i.e. from the command line), they are executed successfully.
Here is the generated command:
find /home/me/downloader/0-29/ -type f | grep -i .rpm$ | xargs -i cp {} /home/me/downloader/builds/0-29/
Here is the error message when it is launched using a python script:
find: paths must precede expression: |
Usage: find [-H] [-L] [-P] [-Olevel] [-D help | tree | search | stat | rates | opt | exec] [path ...] [expression]
Could you help me understand what the problem is?
UPD : here is the function that I use to execute the generated commands:
def exec_command(command):
process = subprocess.Popen(command.split(), stdout=subprocess.PIPE)
output = process.communicate()[0]
return output
source
share