Re: subprocess module usage

2014-09-01 Thread Akira Li
Earl Lapus writes: > Hi, > > I made simple test program using the subprocess module (see attached: > exec_cmd.py). I ran it passing variations of 'ls' command options. > > I encounter exceptions every time I use '-l' options. Example runs > where exception occurs: > # ./exec_cmd.py ls -al > # ./e

Re: subprocess module usage

2014-09-01 Thread Chris Angelico
On Mon, Sep 1, 2014 at 6:46 PM, Cameron Simpson wrote: > Not really. If the arguments are coming in from the command line, someone (a > user, even if that user is the programmer) typed them. Even if not > malicious, they can still be mistaken. Or just unfortunate. I'm guessing that what he means

Re: subprocess module usage

2014-09-01 Thread Cameron Simpson
On 01Sep2014 14:33, Earl Lapus wrote: On Mon, Sep 1, 2014 at 1:39 PM, Chris Angelico wrote: Glad it's working! But please, don't just take my word for it and make a black-box change to your code. When you invoke subprocesses, be sure you understand what's going on, and when shell=True is appro

Re: subprocess module usage

2014-08-31 Thread Earl Lapus
On Mon, Sep 1, 2014 at 1:39 PM, Chris Angelico wrote: > > Glad it's working! But please, don't just take my word for it and make > a black-box change to your code. When you invoke subprocesses, be sure > you understand what's going on, and when shell=True is appropriate and > when shell=False is a

Re: subprocess module usage

2014-08-31 Thread Earl Lapus
On Mon, Sep 1, 2014 at 11:55 AM, Chris Angelico wrote: > > But secondly, you're already splitting the argument (or rather, taking > it from your own parameters, already split), so you don't want to go > through the shell. In fact, going through the shell would only make > your life harder. Change

Re: subprocess module usage

2014-08-31 Thread Chris Angelico
On Mon, Sep 1, 2014 at 3:24 PM, Earl Lapus wrote: > On Mon, Sep 1, 2014 at 11:55 AM, Chris Angelico wrote: >> >> But secondly, you're already splitting the argument (or rather, taking >> it from your own parameters, already split), so you don't want to go >> through the shell. In fact, going thro

Re: subprocess module usage

2014-08-31 Thread Chris Angelico
On Mon, Sep 1, 2014 at 1:28 PM, Earl Lapus wrote: > So, what could be causing this behavior? Is this expected or is there > something wrong with how I'm using the subprocess module? The latter. Your problem is with your shell= option. Firstly, the parameter should be either shell=True or shell=F

Re: subprocess module and long-lived subprocesses

2012-01-20 Thread Nobody
On Fri, 20 Jan 2012 08:42:16 -0600, skip wrote: > The library documentation doesn't talk a lot about long-lived subprocesses > other than the possibility of deadlock when using Popen.wait(). Ideally, I > would write to the subprocess's stdin, check for output on stdout and > stderr, then lather,

Re: subprocess module and long-lived subprocesses

2012-01-20 Thread skip
(Apologies for the non-threaded reply. My subscription to the list is currently set to no-mail and I can't get to gmane.org, so have no clean way to reply...) Mike Fletcher wrote: > Definitely *will* block, you have to explicitly set them non-blocking to > have non-blocking behaviour: ... >

Re: subprocess module and long-lived subprocesses

2012-01-20 Thread Mike C. Fletcher
On 12-01-20 09:42 AM, s...@pobox.com wrote: > I'm converting some os.popen calls to use subprocess.Popen. I had > previously been ignoring stdout and stderr when using os.popen. The primary > motivation to switch to subprocess.Popen now is that I now want to check > stderr, so would have to make

Re: subprocess module under python 2.7

2010-07-27 Thread Chris Rebert
On Tue, Jul 27, 2010 at 4:12 PM, Timothy W. Grove wrote: > I am using the following code to hide the console window when launching a > subprocess under Windows. > >       startupinfo = subprocess.STARTUPINFO() >       startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW >       startupinfo.wShow

Re: Subprocess module: running an interactive shell

2009-03-15 Thread Joe Tyson
On 2009-03-14 20:10:29 -0400, Karthik Gurusamy said: On Mar 14, 3:03 am, Roman Medina-Heigl Hernandez wrote: Karthik Gurusamy escribió: On Mar 13, 6:39 pm, Roman Medina-Heigl Hernandez wrote: Hi, I'm experimenting with Python and I need a little help with this. What I'd like is to

Re: Subprocess module: running an interactive shell

2009-03-14 Thread Karthik Gurusamy
On Mar 14, 3:03 am, Roman Medina-Heigl Hernandez wrote: > Karthik Gurusamy escribió: > > > > > On Mar 13, 6:39 pm, Roman Medina-Heigl Hernandez > > wrote: > >> Hi, > > >> I'm experimenting with Python and I need a little help with this. What I'd > >> like is to launch an interactive shell, having

Re: Subprocess module: running an interactive shell

2009-03-14 Thread Roman Medina-Heigl Hernandez
Karthik Gurusamy escribió: > On Mar 13, 6:39 pm, Roman Medina-Heigl Hernandez > wrote: >> Hi, >> >> I'm experimenting with Python and I need a little help with this. What I'd >> like is to launch an interactive shell, having the chance to send first >> several commands from python. I've written th

Re: Subprocess module: running an interactive shell

2009-03-13 Thread Karthik Gurusamy
On Mar 13, 6:39 pm, Roman Medina-Heigl Hernandez wrote: > Hi, > > I'm experimenting with Python and I need a little help with this. What I'd > like is to launch an interactive shell, having the chance to send first > several commands from python. I've written the following code: > > =

Re: subprocess module: execution of standard binaries without shell?

2009-02-26 Thread Chris Rebert
On Thu, Feb 26, 2009 at 2:41 AM, Visco Shaun wrote: > hi all > > while getting used to with subprocess module i failed in executuing a) > but succeeded in running b). Can anyone explain me why as i am providing > absolute path? Is this has to do anything with shared library.. which > must be acces

Re: subprocess module: execution of standard binaries without shell?

2009-02-26 Thread Christian Heimes
Visco Shaun schrieb: > hi all > > while getting used to with subprocess module i failed in executuing a) > but succeeded in running b). Can anyone explain me why as i am providing > absolute path? Is this has to do anything with shared library.. which > must be accessed based on system variables?

Re: Subprocess module question.

2008-08-20 Thread Gabriel Genellina
En Tue, 19 Aug 2008 22:06:13 -0300, aditya shukla <[EMAIL PROTECTED]> escribi�: I am using windows vista and i am trying to communicate with various processes. so when i do import subprocess proc=subprocess.Popen('cmd.exe') --This opens the command prompt But when i do proc=subprocess.Popen(

Re: subprocess module

2008-07-14 Thread Sebastian "lunar" Wiesner
Peter Otten <[EMAIL PROTECTED]>: > - communicate() waits for the subprocess to terminate. > - stdout.read() is retried if an EINTR occurs (Not sure when this would > happen). EINTR happens, if the "read" syscall is interrupted by a signal handler. For instance, if a daemon handles SIGUSR to re-r

Re: subprocess module

2008-07-14 Thread John Mechaniks
On Jul 14, 7:44 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > John Mechaniks wrote: > > On Jul 14, 12:34 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > >> John Mechaniks wrote: > >> > from subprocess import call > >> > call(['ls', '-l']) > > >> > How do I get the result (not the exit status of the com

Re: subprocess module

2008-07-14 Thread Peter Otten
John Mechaniks wrote: > On Jul 14, 12:34 pm, Peter Otten <[EMAIL PROTECTED]> wrote: >> John Mechaniks wrote: >> > from subprocess import call >> > call(['ls', '-l']) >> >> > How do I get the result (not the exit status of the command) of "ls - >> > l" into a variable? >> >> output = subprocess.Pop

Re: subprocess module

2008-07-14 Thread John Mechaniks
On Jul 14, 12:34 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > John Mechaniks wrote: > > from subprocess import call > > call(['ls', '-l']) > > > How do I get the result (not the exit status of the command) of "ls - > > l" into a variable? > > output = subprocess.Popen(["ls", "-l"], stdout=subproces

Re: subprocess module

2008-07-14 Thread sukkopera
On 14 Lug, 10:34, Peter Otten <[EMAIL PROTECTED]> wrote: > John Mechaniks wrote: > > from subprocess import call > > call(['ls', '-l']) > > > How do I get the result (not the exit status of the command) of "ls - > > l" into a variable? > > output = subprocess.Popen(["ls", "-l"], stdout=subprocess.P

Re: subprocess module

2008-07-14 Thread Peter Otten
John Mechaniks wrote: > from subprocess import call > call(['ls', '-l']) > > How do I get the result (not the exit status of the command) of "ls - > l" into a variable? output = subprocess.Popen(["ls", "-l"], stdout=subprocess.PIPE).stdout.read() Peter -- http://mail.python.org/mailman/listinfo

Re: Subprocess module

2008-04-23 Thread Christian Heimes
[EMAIL PROTECTED] schrieb: > Hello all > > I want to convert a tex file into a pdf by using pdflatex. For that, I > thought the 'subprocess' module might be a good option. My code doesn't work > at all tho: > > Import os, subprocess > > def main(): > scriptpath = os.path.dirname(__file

Re: Subprocess module

2008-04-23 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: Hello all I want to convert a tex file into a pdf by using pdflatex. For that, I thought the 'subprocess' module might be a good option. My code doesn't work at all tho: Import os, subprocess def main(): scriptpath = os.path.dirname(__file__) p = su

Re: subprocess module is sorely deficient?

2008-04-23 Thread Paul Boddie
On 23 Apr, 13:17, Harishankar <[EMAIL PROTECTED]> wrote: > On Wednesday 23 Apr 2008 15:11:21 Ben Kaplan wrote: > > I don't know about all Linux distros, but my Ubuntu machine (8.04 Beta), > > has the 'TERM' (xterm) and 'COLORTERM' (gnome-terminal) keys in os.environ. > > You might be able to use th

Re: subprocess module is sorely deficient?

2008-04-23 Thread Nick Craig-Wood
Mike Hansen <[EMAIL PROTECTED]> wrote: > > I think the best solution would be to port Pexpect to windows which > > wouldn't be that difficult according to my reading of the code. If > > only I had more free time! > > Sage ( http://www.sagemath.org ) uses pexpect fairly extensively to > interfac

Re: subprocess module is sorely deficient?

2008-04-22 Thread Mike Hansen
> I think the best solution would be to port Pexpect to windows which > wouldn't be that difficult according to my reading of the code. If > only I had more free time! Sage ( http://www.sagemath.org ) uses pexpect fairly extensively to interface with all sorts of other systems. We recently recei

Re: subprocess module is sorely deficient?

2008-04-22 Thread sturlamolden
On Apr 22, 12:52 pm, Harishankar <[EMAIL PROTECTED]> wrote: > Sorry to start off on a negative note in the list, but I feel that the Python > subprocess module is sorely deficient because it lacks a mechanism to Have you looked at the processing module in cheese shop? -- http://mail.python.org/m

Re: subprocess module is sorely deficient?

2008-04-22 Thread Harishankar
On Tuesday 22 Apr 2008 17:54:00 Nicola Musatti wrote: > I suggest you check out this: > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554 > > Cheers, > Nicola Musatti > -- > http://mail.python.org/mailman/listinfo/python-list An interesting solution. Thanks a lot for the link. -- Re

Re: subprocess module is sorely deficient?

2008-04-22 Thread Nicola Musatti
On Apr 22, 12:52 pm, Harishankar <[EMAIL PROTECTED]> wrote: > Hi, > > Sorry to start off on a negative note in the list, but I feel that the Python > subprocess module is sorely deficient because it lacks a mechanism to: > > 1. Create non-blocking pipes which can be read in a separate thread (I am

Re: subprocess module is sorely deficient?

2008-04-22 Thread Harishankar
On Tuesday 22 Apr 2008 17:06:26 Paul Boddie wrote: > On 22 Apr, 12:52, Harishankar <[EMAIL PROTECTED]> wrote: > > Is there any way to use non-blocking Popen objects using subprocess? and > > 2 - is there a way to kill the subprocess in a platform independent > > manner in a purely Pythonic way? I t

Re: subprocess module is sorely deficient?

2008-04-22 Thread Paul Boddie
On 22 Apr, 12:52, Harishankar <[EMAIL PROTECTED]> wrote: > > Is there any way to use non-blocking Popen objects using subprocess? and 2 - > is there a way to kill the subprocess in a platform independent manner in a > purely Pythonic way? I thought initially that this problem is simple enough, > bu

Re: Subprocess module and unicode input

2007-09-13 Thread Matthew Lausch
Thanks! That worked perfectly. Matt On Sep 7, 10:42 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Fri, 07 Sep 2007 18:46:26 -0300, Matthew Lausch <[EMAIL PROTECTED]> > escribi?: > > > I'd like to use thesubprocessmodule with upper level characters in > > the process name or in the argume

Re: Subprocess module and unicode input

2007-09-07 Thread Gabriel Genellina
En Fri, 07 Sep 2007 18:46:26 -0300, Matthew Lausch <[EMAIL PROTECTED]> escribi�: > I'd like to use the subprocess module with upper level characters in > the process name or in the arguments to the process. Something like > this: > > cmd = [ u'test_\u65e5\u672c\u8a9e_exec.bat', u'arg1', u'arg2'

Re: subprocess module

2006-07-27 Thread Nick Craig-Wood
placid <[EMAIL PROTECTED]> wrote: > >>> import subprocess > >>> p = subprocess.Popen(["ffmpeg.exe -i video.mpg", "-f mjpeg -ss 5 > >>> -vframes 1 -s 160x120 -an video.gif"], shell=True, stdout=subprocess.PIPE) > > but the ffmpeg complains about the input file being corrupter, whereas > when i

Re: subprocess module

2006-07-22 Thread Tim Roberts
"placid" <[EMAIL PROTECTED]> wrote: >Hi all, > >If someone could give me an example of creating a subprocess (on >Windows) using the subprocess module and Popen class and connecting to >its stdout/stdin file handles. I googled for a bit but the only example >i found was here ; "Use the source, Lu

Re: subprocess module under Windows 98

2005-11-02 Thread Andreas Jung
--On 2. November 2005 08:48:24 -0800 Ernesto <[EMAIL PROTECTED]> wrote: This worked for me on XP... not sure for 98... http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/409002 Thanks, this works! Andreas pgpeWK0kWa6KX.pgp Description: PGP signature -- http://mail.python.org/mailman

Re: subprocess module under Windows 98

2005-11-02 Thread Ernesto
This worked for me on XP... not sure for 98... http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/409002 -- http://mail.python.org/mailman/listinfo/python-list

Re: subprocess module and blocking

2005-06-14 Thread Robin Becker
Dieter Maurer wrote: . > > You just found out that this is not the case. thanks I suppose I was being a moron. > > The warning attached to "communicate"s docstring might have > you averted: "Note: the data read is buffered in memory... > do not use for large size". > > If subprocess would

Re: subprocess module and blocking

2005-06-13 Thread Dieter Maurer
Robin Becker <[EMAIL PROTECTED]> writes on Sun, 12 Jun 2005 09:22:52 +: > I'm using a polling loop in a thread that looks approximately like this > > while 1: > p = find_a_process() > rc = p.poll() > if rc is not None: > out, err = p.communicate() > #deal with