473,385 Members | 1,518 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

subprocess terminate help

def launchWithoutConsole(command, args):
"""Launches 'command' windowless and waits until finished"""
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
return subprocess.Popen([command] + args,
startupinfo=startupinfo).wait()
handle = launchWithoutConsole("program.exe",["disconnect"])
------------------------------------------------------------------------------------------------------------------------------

I've been searching for ways to terminate this process so I can exit my
program. program.exe is a text based interface which I'm running with
python subprocess in a DOS command window. I tried using 'sys.exit()'
to end my program, but nothing works. I think I have to somehow
terminate the subprocesses I create. Any suggestions?

Nov 22 '05 #1
14 3920
Ernesto wrote
I've been searching for ways to terminate this process so I can exit my
program. program.exe is a text based interface which I'm running with
python subprocess in a DOS command window. I tried using 'sys.exit()'
to end my program, but nothing works. I think I have to somehow
terminate the subprocesses I create. Any suggestions?


someone calling himself "Ernesto" posted this link yesterday:

http://aspn.activestate.com/ASPN/Coo.../Recipe/347462

</F>

Nov 22 '05 #2
Ernesto wrote
I've been searching for ways to terminate this process so I can exit my
program. program.exe is a text based interface which I'm running with
python subprocess in a DOS command window. I tried using 'sys.exit()'
to end my program, but nothing works. I think I have to somehow
terminate the subprocesses I create. Any suggestions?


someone calling himself "Ernesto" posted this link yesterday:

http://aspn.activestate.com/ASPN/Coo.../Recipe/347462

</F>

Nov 22 '05 #3
Yeah I know. I posted it b/c I was having the same problems and I'm
investigating ways to do this. None of those methods gave me desired
results for my program. All I want to do is end my python program and
return to the DOS prompt.

Nov 22 '05 #4
Yeah I know. I posted it b/c I was having the same problems and I'm
investigating ways to do this. None of those methods gave me desired
results for my program. All I want to do is end my python program and
return to the DOS prompt.

Nov 22 '05 #5
Ernesto wrote:
Yeah I know. I posted it b/c I was having the same problems and I'm
investigating ways to do this. None of those methods gave me desired
results for my program. All I want to do is end my python program and
return to the DOS prompt.


what about the other program? do you want to terminate that as well ?

</F>

Nov 22 '05 #6
Ernesto wrote:
Yeah I know. I posted it b/c I was having the same problems and I'm
investigating ways to do this. None of those methods gave me desired
results for my program. All I want to do is end my python program and
return to the DOS prompt.


what about the other program? do you want to terminate that as well ?

</F>

Nov 22 '05 #7
Ahhhh... I figured out a way around this. I'll use program.exe to shut
down itself. That way I won't have to use any extension modules.

Thanks!

Nov 22 '05 #8
Ahhhh... I figured out a way around this. I'll use program.exe to shut
down itself. That way I won't have to use any extension modules.

Thanks!

Nov 22 '05 #9
program.exe ? I was looking at the Windows task manager after I used a
Cntrl + C to manually terminate the running python program. The
program.exe is apparently ending when I end the python program.

Nov 22 '05 #10
program.exe ? I was looking at the Windows task manager after I used a
Cntrl + C to manually terminate the running python program. The
program.exe is apparently ending when I end the python program.

Nov 22 '05 #11
Ernesto wrote
program.exe ? I was looking at the Windows task manager after I used a
Cntrl + C to manually terminate the running python program. The
program.exe is apparently ending when I end the python program.


I have to admit that I have no idea what you're doing, really. The code
you used *explicitly* waits for the "program.exe" program to finish. If
you don't want that, why are you telling the subprocess module to wait?
If you do want it to wait, why are you killing the python process ?

</F>

Nov 22 '05 #12
Ernesto wrote
program.exe ? I was looking at the Windows task manager after I used a
Cntrl + C to manually terminate the running python program. The
program.exe is apparently ending when I end the python program.


I have to admit that I have no idea what you're doing, really. The code
you used *explicitly* waits for the "program.exe" program to finish. If
you don't want that, why are you telling the subprocess module to wait?
If you do want it to wait, why are you killing the python process ?

</F>

Nov 22 '05 #13
Hi!

Self-destruction of a script:

import os
os.popen('TASKKILL /PID '+str(os.getpid())+' /F')

(only in windows XP or 2K)
@-salutations

Michel Claveau

Nov 22 '05 #14
Hi!

Self-destruction of a script:

import os
os.popen('TASKKILL /PID '+str(os.getpid())+' /F')

(only in windows XP or 2K)
@-salutations

Michel Claveau

Nov 22 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: jelle | last post by:
Hi, I'm using the subprocess module to run a open-source lighting simulation software, Radiance, and am using python to script it. When Radiance finds a scene where no light is present its...
1
by: py | last post by:
I am using subprocess.Popen to execute an executable, how can I terminate that process when I want? for example (on windows) p = subprocess.Popen("calc.exe") ..... now say I want to kill...
0
by: Ernesto | last post by:
def launchWithoutConsole(command, args): """Launches 'command' windowless and waits until finished""" startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW...
6
by: Ernesto | last post by:
I'm opening a telnet session with the subprocess call below. I then wait ten seconds and attempt to terminate the telnet window I created. Unfortuantely, the telnet window remains after the...
11
by: 7stud | last post by:
Hi, Can someone explain what a broken pipe is? The following produces a broken pipe error: ---------- import subprocess as sub p = sub.Popen(, stdin=sub.PIPE, stdout=sub.PIPE)
9
by: Phoe6 | last post by:
Hi all, Consider this scenario, where in I need to use subprocess to execute a command like 'ping 127.0.0.1' which will have a continuous non- terminating output in Linux. # code # This...
1
by: | last post by:
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 atall tho: Import os, subprocess ...
6
by: John Mechaniks | last post by:
from subprocess import call call() How do I get the result (not the exit status of the command) of "ls - l" into a variable?
5
by: thedsadude | last post by:
Hello, I'm launching a script as follows: <code> p = subprocess.Popen() p.wait() </code> If p.py writes to sys.stdout, then it is shown on the console.
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.