os.system and subprocess odd behavior

Oscar Benjamin oscar.j.benjamin at gmail.com
Tue Dec 18 19:52:46 CET 2012

Can you trim content and interleave your response (instead of
top-posting) please?

On 18 December 2012 18:26, py_genetic <conor.robinson at gmail.com> wrote:
> when using this command from before.... no dice
> /usr/local/Calpont/mysql/bin/mysql --defaults-file=/usr/local/Calpont/mysql/my.cnf -u root myDB < /home/myusr/jobs/APP_JOBS/JOB_XXX.SQL > /home/myusr/jobs/APP_JOBS/JOB_XXX.TXT
> OR
> /usr/local/Calpont/mysql/bin/mysql --defaults-file=/usr/local/Calpont/mysql/my.cnf -u root myDB < /home/myusr/jobs/APP_JOBS/JOB_XXX.SQL | sudo tee /home/myusr/jobs/APP_JOBS/JOB_XXX.TXT
> So it's basically as if python gets a response instantly (perhaps from the query) and closes the process, since we've verified its not permissions related.

I wouldn't say that this is verified.

Have you verified that without the last redirection (to the output
file) you can correctly read the stdout from within Python?

Does the same command work if you put it in a shell script? If so what
about making a script like so:

#!/usr/bin/env bash


--defaults-file=/usr/local/Calpont/mysql/my.cnf -u root myDB <
"/home/myusr/jobs/APP_JOBS/JOB_${jobname}.SQL" | sudo tee

If that works when you run it directly, does it work if you do:
subprocess.check_call(['myscript.sh', jobname])


More information about the Python-list mailing list