Re: [Tutor] os command

2005-11-02 Thread Hugo González Monteverde
Hi Johan Geldenhuys wrote: > Hugo, > > I see that 'os.execcvp()' doesn't actually make two seperate processes. > This is what I have working now: > """ > > import os, signal, time > pid = os.fork() > print 'pid; ',pid > if pid == 0: #child process >#os.execvp('tcpdump', ['tcpdump',

Re: [Tutor] os command

2005-11-02 Thread Hugo González Monteverde
Hi Johan Geldenhuys wrote: > Hugo, > > I see that 'os.execcvp()' doesn't actually make two seperate processes. > This is what I have working now: > """ > > import os, signal, time > pid = os.fork() > print 'pid; ',pid > if pid == 0: #child process >#os.execvp('tcpdump', ['tcpdump',

Re: [Tutor] os command

2005-11-02 Thread Johan Geldenhuys
Hugo, I see that 'os.execcvp()' doesn't actually make two seperate processes. The advice you gave me works good. I just had to fgure out with what params I should call it. I'm still a bit unsure of how to call the sysem command with more than one argument. This is what I have working now: """

Re: [Tutor] os command

2005-11-02 Thread Hugo González Monteverde
In UNIX, you use the fork() exec() technique for starting a new process, from the very first process(init) onwards. The os.system() uses a shell to do that, or you may do it yourself (in your script) A "command" is just an executable file running(process), unless you've got a library function

Re: [Tutor] os command

2005-11-02 Thread Johan Geldenhuys
Sorry for the late reply, But is it necessary to use a child process? I don't want to execute the command in another process. What happens with the parent process and how do I execute my command in the parent process? Thanks Hugo González Monteverde wrote: > Hi, > > os.system will return the e

Re: [Tutor] os command

2005-10-26 Thread Hugo González Monteverde
Hi, os.system will return the errorval of the application. You need to 1) get the pid of the child process 2) kill it using os.kill(os.SIGTERM) 3) reap the killed process This is all in unix/linux, of course. what I do (untested, please check order of args and correct usage of exec): pid = os.

Re: [Tutor] os command

2005-10-26 Thread Johan Geldenhuys
So, for a newbie like me I might struggle with this one :-( I saw that the thread in comp.lang.python talks about a deamon flag for a thread. This sounds like a idea that could work. I don't know how to use that, but will use the example given there. Thanks. Kent Johnson wrote: Johan Ge

Re: [Tutor] os command

2005-10-26 Thread Kent Johnson
Johan Geldenhuys wrote: > I have script that calls a system command that I want to run for 5 minutes. > """ > import os > cmd = 'tcpdump -n -i eth0' > os.system(cmd) > """ > > I can start a timer after the cmd is issued, but I don't know how to > send a control signal to stop the command after I

[Tutor] os command

2005-10-26 Thread Johan Geldenhuys
I have script that calls a system command that I want to run for 5 minutes. """ import os cmd = 'tcpdump -n -i eth0' os.system(cmd) """ I can start a timer after the cmd is issued, but I don't know how to send a control signal to stop the command after I issued it. This is normally from the shel