Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #35065

Re: os.system and subprocess odd behavior

References (2 earlier) <8757bcac-76ac-4b15-9410-dc61d7a8c641@googlegroups.com> <mailman.970.1355764606.29569.python-list@python.org> <0e224780-b84f-4f72-9c95-bc55cde8b183@googlegroups.com> <mailman.1004.1355790699.29569.python-list@python.org> <6ff54b92-70f1-44fb-a5a5-17133e1a6faa@googlegroups.com>
Date 2012-12-18 18:52 +0000
Subject Re: os.system and subprocess odd behavior
From Oscar Benjamin <oscar.j.benjamin@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1024.1355856768.29569.python-list@python.org> (permalink)

Show all headers | View raw


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

On 18 December 2012 18:26, py_genetic <conor.robinson@gmail.com> wrote:
> HOWEVER...
>
> 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

jobname="$1"

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

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


Oscar

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

os.system and subprocess odd behavior py_genetic <conor.robinson@gmail.com> - 2012-12-14 10:13 -0800
  Re: os.system and subprocess odd behavior Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-12-14 22:47 +0000
    Re: os.system and subprocess odd behavior py_genetic <conor.robinson@gmail.com> - 2012-12-17 08:39 -0800
      Re: os.system and subprocess odd behavior Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-12-17 17:16 +0000
        Re: os.system and subprocess odd behavior py_genetic <conor.robinson@gmail.com> - 2012-12-17 12:56 -0800
          Re: os.system and subprocess odd behavior Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-12-18 00:01 +0000
            Re: os.system and subprocess odd behavior py_genetic <conor.robinson@gmail.com> - 2012-12-18 10:26 -0800
              Re: os.system and subprocess odd behavior Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-12-18 18:52 +0000
                Re: os.system and subprocess odd behavior py_genetic <conor.robinson@gmail.com> - 2012-12-18 12:52 -0800
                Re: os.system and subprocess odd behavior py_genetic <conor.robinson@gmail.com> - 2012-12-18 12:52 -0800
            Re: os.system and subprocess odd behavior py_genetic <conor.robinson@gmail.com> - 2012-12-18 10:26 -0800
          Re: os.system and subprocess odd behavior Hans Mulder <hansmu@xs4all.nl> - 2012-12-18 23:46 +0100
        Re: os.system and subprocess odd behavior py_genetic <conor.robinson@gmail.com> - 2012-12-17 12:56 -0800
  Re: os.system and subprocess odd behavior Dieter Maurer <dieter@handshake.de> - 2012-12-15 08:12 +0100
    Re: os.system and subprocess odd behavior py_genetic <conor.robinson@gmail.com> - 2012-12-17 08:30 -0800
    Re: os.system and subprocess odd behavior py_genetic <conor.robinson@gmail.com> - 2012-12-17 08:30 -0800
  Re: os.system and subprocess odd behavior photonymous@gmail.com - 2012-12-17 21:10 -0800
    Re: os.system and subprocess odd behavior Hans Mulder <hansmu@xs4all.nl> - 2012-12-18 11:27 +0100
      Re: os.system and subprocess odd behavior Dave Angel <d@davea.name> - 2012-12-18 05:39 -0500
        Re: os.system and subprocess odd behavior Hans Mulder <hansmu@xs4all.nl> - 2012-12-18 12:40 +0100

csiph-web