Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > python spawn new process, rout stdin/out

Reply
Thread Tools

python spawn new process, rout stdin/out

 
 
kmkz89@gmail.com
Guest
Posts: n/a
 
      02-09-2006
Hi,

I'm trying to make a program that acts as an intermediate between the
user and another executable. When my python program is executed, I
would like another .exe to be spawned within the python program, and
the stdin/stdout to be routed from the user to the program. So if my
program is booted into a console window, anything typed by the user
will be passed to the subprocess and any output from that executable
will appear in the console, showing the user what happened. In
addition, when the python program is closed, the subprocess should be
closed.

Any ideas how to do this? I am far from a Python newbie but I know
little to nothing about os.*/subprocess.* so I need quite a bit of
assistance.

Thanks guys!
kmkz

 
Reply With Quote
 
 
 
 
Farshid Lashkari
Guest
Posts: n/a
 
      02-10-2006
Sounds like the popen2 module should suffice. Take a look at the
documentation for the module here:

http://www.python.org/doc/lib/module-popen2.html

-Farshid
 
Reply With Quote
 
 
 
 
kmkz
Guest
Posts: n/a
 
      02-17-2006
How exactly do I map the main program's STDOUT (what the user sees) to
the subprocess' STDOUT? In effect I want it to appear as though they
just executed the program itself.

 
Reply With Quote
 
kmkz
Guest
Posts: n/a
 
      02-17-2006
ok solved that by using the call() method

I now have a bigger problem: the executable always wants to open in its
own window. how do I stop this?

 
Reply With Quote
 
Steve Holden
Guest
Posts: n/a
 
      02-18-2006
kmkz wrote:
> ok solved that by using the call() method
>
> I now have a bigger problem: the executable always wants to open in its
> own window. how do I stop this?
>

Call pythonw instead of python.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Logging stdout/stderr/stdin of an spawn process (Open4::spawn) Edgardo Hames Ruby 1 05-06-2008 08:17 PM
Logging stdout/stderr/stdin of an spawn process (Open4::spawn) Ed Hames Ruby 0 04-16-2008 04:21 PM
Setting up a network using a desktop and laptop on a wireless rout =?Utf-8?B?RG9kZ2Vib3k=?= Wireless Networking 5 08-22-2005 07:07 PM
spawn syntax + os.P_WAIT mode behavior + spawn stdout redirection Derek Basch Python 2 01-21-2005 05:37 AM
what is "Timing Score" in place & rout report spartan VHDL 1 08-17-2004 11:48 AM



Advertisments