Re: [Tutor] os.system vs subprocess.Popen args problems

2013-09-04 Thread eryksun
On Wed, Sep 4, 2013 at 7:11 AM, Oscar Benjamin wrote: > On 4 September 2013 11:42, eryksun wrote: si = subprocess.STARTUPINFO() si.dwFlags |= subprocess.STARTF_USESHOWWINDOW si.wShowWindow = subprocess.SW_HIDE >>> >>> Do these statements modify module-level state? Or do

Re: [Tutor] os.system vs subprocess.Popen args problems

2013-09-04 Thread Oscar Benjamin
On 4 September 2013 11:42, eryksun wrote: >>> si = subprocess.STARTUPINFO() >>> si.dwFlags |= subprocess.STARTF_USESHOWWINDOW >>> si.wShowWindow = subprocess.SW_HIDE >> >> Do these statements modify module-level state? Or do you need to pass >> startupinfo=si when calling Popen? > > It

Re: [Tutor] os.system vs subprocess.Popen args problems

2013-09-04 Thread eryksun
On Wed, Sep 4, 2013 at 6:22 AM, Oscar Benjamin wrote: > On 4 September 2013 11:11, eryksun wrote: > >> Using shell=True also sets startupinfo to hide the window. If that's >> the only reason you're using the shell, you may as well cut out the >> middleman (and potential security hole). Set startu

Re: [Tutor] os.system vs subprocess.Popen args problems

2013-09-04 Thread Oscar Benjamin
On 4 September 2013 11:11, eryksun wrote: > On Wed, Sep 4, 2013 at 5:14 AM, learner404 wrote: >> >> Yes, this worked :) >> >> subprocess.Popen(["ffmpeg","-f","dshow","-i","video="+videoinputName,"-f", >> "dshow","-i","audio="+audioinputName,"-q","5","%s"%videoFileOutput], >> shell=True) You shou

Re: [Tutor] os.system vs subprocess.Popen args problems

2013-09-04 Thread eryksun
On Wed, Sep 4, 2013 at 5:14 AM, learner404 wrote: > > Yes, this worked :) > > subprocess.Popen(["ffmpeg","-f","dshow","-i","video="+videoinputName,"-f", > "dshow","-i","audio="+audioinputName,"-q","5","%s"%videoFileOutput], > shell=True) Using shell=True also sets startupinfo to hide the window.

Re: [Tutor] os.system vs subprocess.Popen args problems

2013-09-04 Thread learner404
Thanks a lot Oscar and Eryksun for all the explanations and answers, I really appreciate. "So the extra quotes used for the video and audio arguments do actually get passed through to ffmpeg causing confusion." Yes, this worked :) subprocess.Popen(["ffmpeg","-f","dshow","-i","video="+videoinputNa

Re: [Tutor] os.system vs subprocess.Popen args problems

2013-09-03 Thread Oscar Benjamin
On 3 September 2013 14:48, eryksun wrote: >> It occurs to me that another possibility is if ffmpeg isn't really an >> .exe on PATH but rather a .bat file or something. In that case >> os.system or subprocess shell=True would pick it up but subprocess >> shell=False might not. I say "might" because

Re: [Tutor] os.system vs subprocess.Popen args problems

2013-09-03 Thread eryksun
On Tue, Sep 3, 2013 at 5:54 AM, Oscar Benjamin wrote: > On 3 September 2013 05:49, eryksun wrote: > > I've previously tried to find documentation that explains how MSVCRT > handles this. I didn't find anything as explicit as the explanation in > the subprocess docs. For example: > http://msdn.mic

Re: [Tutor] os.system vs subprocess.Popen args problems

2013-09-03 Thread Oscar Benjamin
On 3 September 2013 05:49, eryksun wrote: > On Mon, Sep 2, 2013 at 10:19 AM, learner404 wrote: >> >> I can't understand why the command below works with os.system but not with >> subprocess.Popen (on windows, recording video with FFMPEG.exe) >> >> cmd=('ffmpeg -f dshow -i video="%s" -f dshow -i a

Re: [Tutor] os.system vs subprocess.Popen args problems

2013-09-02 Thread eryksun
On Mon, Sep 2, 2013 at 10:19 AM, learner404 wrote: > > I can't understand why the command below works with os.system but not with > subprocess.Popen (on windows, recording video with FFMPEG.exe) > > cmd=('ffmpeg -f dshow -i video="%s" -f dshow -i audio="%s" -q 5 "%s"')% > (videoinputName, audioinp

Re: [Tutor] os.system vs subprocess.Popen args problems

2013-09-02 Thread Oscar Benjamin
On 2 September 2013 15:19, learner404 wrote: > Hello, > > I can't understand why the command below works with os.system but not with > subprocess.Popen (on windows, recording video with FFMPEG.exe) > > cmd=('ffmpeg -f dshow -i video="%s" -f dshow -i audio="%s" -q 5 > "%s"')%(videoinputName, audioi

[Tutor] os.system vs subprocess.Popen args problems

2013-09-02 Thread learner404
Hello, I can't understand why the command below works with os.system but not with subprocess.Popen (on windows, recording video with FFMPEG.exe) cmd=('ffmpeg -f dshow -i video="%s" -f dshow -i audio="%s" -q 5 "%s"')%(videoinputName, audioinputName, videoFileOutput) os.system(cmd) *works* subpro

Re: [Tutor] os.system() not working

2013-08-28 Thread Chris Down
On 2013-08-28 08:16, wolfrage8...@gmail.com wrote: > PHP is not Python. You misread. > > I have a python program which i am calling from a php script. pgpqqKjmHTR5l.pgp Description: PGP signature ___ Tutor maillist - Tutor@python.org To unsubscribe

Re: [Tutor] os.system() not working

2013-08-28 Thread wolfrage8...@gmail.com
On Tue, Aug 27, 2013 at 6:33 AM, Nitish Kunder wrote: > Hii > I have a python program which i am calling from a php script. > The arguments to the program is a path to the file > The program when directly run from console executes normally. > But when I try to execute the program from browser ie c

Re: [Tutor] os.system() not working

2013-08-27 Thread Dominik George
Hi, in any case and apart from what was already said, your setup sounds very awkward, if not insane. Are you sure your implementation is a good idea? -nik Nitish Kunder schrieb: >Hii >I have a python program which i am calling from a php script. >The arguments to the program is a path to th

Re: [Tutor] os.system() not working

2013-08-27 Thread Chris Down
Hello, On 2013-08-27 16:03, Nitish Kunder wrote: > I have a python program which i am calling from a php script. > The arguments to the program is a path to the file > The program when directly run from console executes normally. > But when I try to execute the program from browser ie call the pyt

Re: [Tutor] os.system() not working

2013-08-27 Thread Alan Gauld
On 27/08/13 11:33, Nitish Kunder wrote: I have a python program which i am calling from a php script. How are you executing the PHP script? Which OS? Which web server? Which browser? Have you tried others? The arguments to the program is a path to the file The program when directly run from c

[Tutor] os.system() not working

2013-08-27 Thread Nitish Kunder
Hii I have a python program which i am calling from a php script. The arguments to the program is a path to the file The program when directly run from console executes normally. But when I try to execute the program from browser ie call the python script from php, os.system command is not working

Re: [Tutor] os.system() with imbeded quotes

2013-04-04 Thread Kushal Kumaran
cevyn e writes: > I get the example os.system('ls -al') no problem. > > i'm trying to create a variable with my command built but needs to include > quotes. > Portion of code is as follows: > someip = '192.168.01.01' > > var1 = 'lynx -dump http://' + someip + > '/cgi-bin/.log&.submit=+++G

[Tutor] os.system() with imbeded quotes

2013-04-04 Thread cevyn e
I get the example os.system('ls -al') no problem. i'm trying to create a variable with my command built but needs to include quotes. Portion of code is as follows: someip = '192.168.01.01' var1 = 'lynx -dump http://' + someip + '/cgi-bin/.log&.submit=+++Go%21+++ > junk' print var1 os.

Re: [Tutor] os.system

2010-12-17 Thread Steven D'Aprano
jtl999 wrote: I want to pass a variable to os.system which is dir dir=raw_input ("Dir Please ") Dir Please / ok dir = / os.system ("ls" + dir) sh: ls/: No such file or directory 32512 any advice Yes -- learn to read the error messages you get. The error you get is a shell error, not a P

Re: [Tutor] os.system

2010-12-17 Thread wesley chun
On Fri, Dec 17, 2010 at 4:17 PM, Emile van Sebille wrote: > On 12/17/2010 4:07 PM jtl999 said... >> >> I want to pass a variable to os.system which is dir > dir=raw_input ("Dir Please ") > os.system ("ls"  + dir) >> sh: ls/: No such file or directory > > this has concatenated "ls" and dir

Re: [Tutor] os.system

2010-12-17 Thread Emile van Sebille
On 12/17/2010 4:07 PM jtl999 said... I want to pass a variable to os.system which is dir dir=raw_input ("Dir Please ") Dir Please / ok dir = / os.system ("ls" + dir) sh: ls/: No such file or directory this has concatenated "ls" and dir try with "ls " Emile 32512 any advice __

[Tutor] os.system

2010-12-17 Thread jtl999
I want to pass a variable to os.system which is dir >>> dir=raw_input ("Dir Please ") Dir Please / ok dir = / >>> os.system ("ls" + dir) sh: ls/: No such file or directory 32512 any advice signature.asc Description: This is a digitally signed message part _

Re: [Tutor] os.system and/or subprocess.call problem...

2009-07-10 Thread daychilde
: > self.fh.close : > : > Which doesn't show where the vars come from, but I am closing the : file : > first. : : Actually, no, it doesn't. You forgot the () which are needed to : actually _call_ the close method on the last line. : :self.fh.close : : is an expression which evaluate

Re: [Tutor] os.system and/or subprocess.call problem...

2009-07-10 Thread Emile van Sebille
On 7/10/2009 10:24 AM daychi...@gmail.com said... : Actually it sounds like you're calling it iteratively, not recursively. :blush: Indeed. : From what you write in here, my first thought is that the ini file : isn't being flushed out to disk before the subprocess starts up and : tries to rea

Re: [Tutor] os.system and/or subprocess.call problem...

2009-07-10 Thread Steve Willoughby
On Fri, Jul 10, 2009 at 12:22:24PM -0500, daychi...@gmail.com wrote: > self.filename = 'bsf.ini' > self.fullpath = self.thispath + self.filename > self.fh = open(self.fullpath, 'w') > self.fh.write(self.bsf_ini) > self.fh.close > > Which doesn't show where t

Re: [Tutor] os.system and/or subprocess.call problem...

2009-07-10 Thread daychilde
: Actually it sounds like you're calling it iteratively, not recursively. :blush: Indeed. : From what you write in here, my first thought is that the ini file : isn't being flushed out to disk before the subprocess starts up and : tries to read it. : : Are you either calling .flush() or .close(

Re: [Tutor] os.system and/or subprocess.call problem...

2009-07-10 Thread Bill Campbell
On Fri, Jul 10, 2009, daychi...@gmail.com wrote: >I'm working on a program that calls another program recursively - this other >program reads in ini file and processes it; my program creates a number of >slightly different ini files and calls the other program for each one. > >I can successfully ge

Re: [Tutor] os.system and/or subprocess.call problem...

2009-07-10 Thread Steve Willoughby
On Fri, Jul 10, 2009 at 12:00:11PM -0500, daychi...@gmail.com wrote: > I'm working on a program that calls another program recursively - this other Actually it sounds like you're calling it iteratively, not recursively. > I can successfully generate the ini file. The problem is that the other > p

[Tutor] os.system and/or subprocess.call problem...

2009-07-10 Thread daychilde
I'm working on a program that calls another program recursively - this other program reads in ini file and processes it; my program creates a number of slightly different ini files and calls the other program for each one. I can successfully generate the ini file. The problem is that the other pro

Re: [Tutor] os.system() problem

2008-02-05 Thread Eric Brunson
Aditya Lal wrote: > On 04/02/08 10:42 PM, "Eric Brunson" <[EMAIL PROTECTED]> wrote: > > >> dave selby wrote: >> >>> Hi all, >>> >>> I am not sure if this is a Python or bash issue :). >>> >>> In bash if I execute 'motion' with the following ... >>> >>> [EMAIL PROTECTED]:~/.kde/share/apps/km

Re: [Tutor] os.system() problem

2008-02-05 Thread Aditya Lal
On 04/02/08 10:42 PM, "Eric Brunson" <[EMAIL PROTECTED]> wrote: > dave selby wrote: >> Hi all, >> >> I am not sure if this is a Python or bash issue :). >> >> In bash if I execute 'motion' with the following ... >> >> [EMAIL PROTECTED]:~/.kde/share/apps/kmotion$ motion &> /dev/null & >> [1] 10

Re: [Tutor] os.system() problem

2008-02-04 Thread Eric Brunson
dave selby wrote: > Hi all, > > I am not sure if this is a Python or bash issue :). > > In bash if I execute 'motion' with the following ... > > [EMAIL PROTECTED]:~/.kde/share/apps/kmotion$ motion &> /dev/null & > [1] 10734 > [EMAIL PROTECTED]:~/.kde/share/apps/kmotion$ > > I get what I expect, a b

Re: [Tutor] os.system() problem

2008-02-03 Thread Michael Langford
Popen may be a better call for what you're trying to do. Some of the higher numbered popens will give you the stderr stream. The lowered numbered ones are probably all you need. http://docs.python.org/lib/node529.html --Michael On Feb 3, 2008 12:54 PM, dave selby <[EMAIL PROTECTED]> wrote

[Tutor] os.system() problem

2008-02-03 Thread dave selby
Hi all, I am not sure if this is a Python or bash issue :). In bash if I execute 'motion' with the following ... [EMAIL PROTECTED]:~/.kde/share/apps/kmotion$ motion &> /dev/null & [1] 10734 [EMAIL PROTECTED]:~/.kde/share/apps/kmotion$ I get what I expect, a background job, however if I execute

Re: [Tutor] os.system() with NO_WAIT

2006-08-08 Thread János Juhász
quot;wesley chun" <[EMAIL PROTECTED]> 2006.08.07 22:28 To "János Juhász" <[EMAIL PROTECTED]> cc tutor@python.org Subject Re: [Tutor] os.system() with NO_WAIT >         os.system('vedicom.exe') > > Have you got any idea how I can strart this windows GU

Re: [Tutor] os.system() with NO_WAIT

2006-08-07 Thread wesley chun
> os.system('vedicom.exe') > > Have you got any idea how I can strart this windows GUI program with not > waiting its return. instead of os.system(), you want to use the subprocess module if you are using Python 2.4+: http://docs.python.org/lib/module-subprocess.html calling subprocess.Po

[Tutor] os.system() with NO_WAIT

2006-08-07 Thread János Juhász
Dear Guys, I have a small script that is running on a terminal server's client session. ### import os import time import glob def send():     print 'I am checking %s' % time.ctime()     if len(glob.glob(r'U:\ediout\DESADV\*.doc')) > 0:         os.system('vedicom.exe') if __name__ == '__mai

Re: [Tutor] os.system sending of break signals

2005-10-28 Thread Alan Gauld
>> to do that you need to find the process ID. I'm not sure if >> popen() provides access to the PID but if not you could >> either search for it (this might be too slow) or just drop >> down to use fork rather than popen, as fork will return >> the PID. > >Would calling PS via another popen() and

Re: [Tutor] os.system sending of break signals

2005-10-28 Thread Liam Clarke
On 10/28/05, Alan Gauld <[EMAIL PROTECTED]> wrote: > > >>> f = os.popen2('ping 192.168.8.85 -c 100 > cap1.txt') > > >>> f[0].write('\x03') > > > > Thank command works, but 'f[1]' is in read-only mode and I can't write > > to it. > > My command in the background is still not terminated. > > Thats al

Re: [Tutor] os.system sending of break signals

2005-10-28 Thread Liam Clarke
Alan Gauld wrote: > > You can read the output of popen into your program with > f.read(), but that will read all of the output after the program > has run. However I think you can readline() too to catch it > line by line. You can also write() data to f thus allowing you > to send your Ctrl-C.(You

Re: [Tutor] os.system sending of break signals

2005-10-28 Thread Kent Johnson
Johan Geldenhuys wrote: > So far: > I tried > >>> f = os.popen('ping 192.168.8.85 -c 100 > cap2.txt') > > You will see that I send the output from the command to a file, because > I want to test how stop the command before it reaches 100 pings. > If I don't write the output to the file 'cap2.txt

Re: [Tutor] os.system sending of break signals

2005-10-28 Thread Johan Geldenhuys
With what can I try and see what the PID is when using popen() or popen2() ? One thing that I noticed now is that when using popen() and the sys.exit(). The command is completed before my Python shell is terminated and if I use popen2(), sys.exit() works immediately but the ping command runs st

Re: [Tutor] os.system sending of break signals

2005-10-28 Thread Alan Gauld
> >>> f = os.popen2('ping 192.168.8.85 -c 100 > cap1.txt') > >>> f[0].write('\x03') > > Thank command works, but 'f[1]' is in read-only mode and I can't write > to it. > My command in the background is still not terminated. Thats almost certainly because ping never reads its input. In that case

Re: [Tutor] os.system sending of break signals

2005-10-28 Thread Johan Geldenhuys
If I use popen2, I need to write to one of the tuple parts. >>> f = os.popen2('ping 192.168.8.85 -c 100 > cap1.txt') >>> f[0].write('\x03') Thank command works, but 'f[1]' is in read-only mode and I can't write to it. My command in the background is still not terminated. BTW I use Linux as OS.

Re: [Tutor] os.system sending of break signals

2005-10-28 Thread Alan Gauld
> >>> f = os.popen('ping 192.168.8.85 -c 100 > cap2.txt') > > You will see that I send the output from the command to a file, because > I want to test how stop the command before it reaches 100 pings. > If I don't write the output to the file 'cap2.txt' and succeeds in > closing 'f', all the dat

Re: [Tutor] os.system sending of break signals

2005-10-28 Thread Alan Gauld
> Python has a "signal" module in the standard library. Will that work? Yes potentially, but you still need to mess about with process ids etc to find which process to send the signal... And you would have to do the two things in separate threads since system() blocks your main program. Alan g

Re: [Tutor] os.system sending of break signals

2005-10-28 Thread Johan Geldenhuys
So far: I tried >>> f = os.popen('ping 192.168.8.85 -c 100 > cap2.txt') You will see that I send the output from the command to a file, because I want to test how stop the command before it reaches 100 pings. If I don't write the output to the file 'cap2.txt' and succeeds in closing 'f', all th

Re: [Tutor] os.system sending of break signals

2005-10-27 Thread R. Alan Monroe
>> I send a command to os.system(cmd) and want to send a break signal in >> the same way. Is this possible? The break signal is ctrl c (^c). >> I tried this, but it didn't work: os.system('\x03') I think Hex 03 is >> the signal for ctrl c. > Its not possible with os.system because os.system runs

Re: [Tutor] os.system sending of break signals

2005-10-27 Thread Alan Gauld
> I send a command to os.system(cmd) and want to send a break signal in > the same way. Is this possible? The break signal is ctrl c (^c). > I tried this, but it didn't work: os.system('\x03') I think Hex 03 is > the signal for ctrl c. Its not possible with os.system because os.system runs the c

Re: [Tutor] os.system sending of break signals

2005-10-27 Thread Hugo González Monteverde
Even if you could send a break signal, it would go to a new shell that os.system() invokes... Perhaps you know or can get the ID of the process you want to signal, a ctrl-c in a shell is equivalent to a SIGINT sent using os.kill() Please anyone in the list correct me if there is something I mis

[Tutor] os.system sending of break signals

2005-10-27 Thread Johan Geldenhuys
Hi all, I send a command to os.system(cmd) and want to send a break signal in the same way. Is this possible? The break signal is ctrl c (^c). I tried this, but it didn't work: os.system('\x03') I think Hex 03 is the signal for ctrl c. Thanks, ___ Tu