Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > popen2

Reply
Thread Tools

popen2

 
 
g.franzkowiak
Guest
Posts: n/a
 
      10-28-2005
I start a process in my application with popen2.popen3('MyOtherProcess').
That's ok, but what can I do if the other process is running ?
Can I fetch some information and start with that ?

gerd
 
Reply With Quote
 
 
 
 
David Wahler
Guest
Posts: n/a
 
      10-28-2005
g.franzkowiak wrote:
> I start a process in my application with popen2.popen3('MyOtherProcess').
> That's ok, but what can I do if the other process is running ?
> Can I fetch some information and start with that ?
>
> gerd


It's not clear what you're asking for. Could you please clarify?

-- David

 
Reply With Quote
 
 
 
 
g.franzkowiak
Guest
Posts: n/a
 
      10-28-2005
David Wahler schrieb:
> g.franzkowiak wrote:
>
>>I start a process in my application with popen2.popen3('MyOtherProcess').
>>That's ok, but what can I do if the other process is running ?
>>Can I fetch some information and start with that ?
>>
>>gerd

>
>
> It's not clear what you're asking for. Could you please clarify?
>
> -- David
>


If starts a process with popen2.popen3('myprogram') and myprogram.exe is
running before, I've a connection to the second process, not to the first.
I can find the process by name before I start a process with popen2...,
but how bcan I connect t this process with a pipe ?

gerd
 
Reply With Quote
 
Dennis Lee Bieber
Guest
Posts: n/a
 
      10-29-2005
On Fri, 28 Oct 2005 22:16:56 +0200, "g.franzkowiak"
<(E-Mail Removed)> declaimed the following in
comp.lang.python:

>
> If starts a process with popen2.popen3('myprogram') and myprogram.exe is
> running before, I've a connection to the second process, not to the first.
> I can find the process by name before I start a process with popen2...,
> but how bcan I connect t this process with a pipe ?
>

As I understand it... you Don't...

The OS sets up the pipes as substitutes for stdin/stdout when it
starts the process. The process itself doesn't know if stdin is a file,
some virtual pipe, a keyboard, etc.

Once the process has started, it is accessing stdin/stdout -- you
would have to somehow go inside of the process and change all file
handles/descriptors that were going to stdin/stdout to now go to your
pipe
--
> ================================================== ============ <
> http://www.velocityreviews.com/forums/(E-Mail Removed) | Wulfraed Dennis Lee Bieber KD6MOG <
> (E-Mail Removed) | Bestiaria Support Staff <
> ================================================== ============ <
> Home Page: <http://www.dm.net/~wulfraed/> <
> Overflow Page: <http://wlfraed.home.netcom.com/> <

 
Reply With Quote
 
Piet van Oostrum
Guest
Posts: n/a
 
      10-29-2005
>>>>> "g.franzkowiak" <(E-Mail Removed)> (gf) wrote:

>gf> If starts a process with popen2.popen3('myprogram') and myprogram.exe is
>gf> running before, I've a connection to the second process, not to the first.
>gf> I can find the process by name before I start a process with popen2...,
>gf> but how bcan I connect t this process with a pipe ?


You have to use a named pipe.

--
Piet van Oostrum <(E-Mail Removed)>
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4]
Private email: (E-Mail Removed)
 
Reply With Quote
 
Grant Edwards
Guest
Posts: n/a
 
      10-29-2005
On 2005-10-29, Piet van Oostrum <(E-Mail Removed)> wrote:
>>>>>> "g.franzkowiak" <(E-Mail Removed)> (gf) wrote:

>
>>gf> If starts a process with popen2.popen3('myprogram') and myprogram.exe is
>>gf> running before, I've a connection to the second process, not to the first.
>>gf> I can find the process by name before I start a process with popen2...,
>>gf> but how bcan I connect t this process with a pipe ?

>
> You have to use a named pipe.


That would require that the application know about the named
pipe and open it. I don't think there is any way to swap a
pipe in for stdin/stdout once a process is running.

--
Grant Edwards grante Yow! NOW, I'm supposed
at to SCRAMBLE two, and HOLD
visi.com th' MAYO!!
 
Reply With Quote
 
Pierre Hanser
Guest
Posts: n/a
 
      10-29-2005
Grant Edwards a écrit :
> On 2005-10-29, Piet van Oostrum <(E-Mail Removed)> wrote:
>
>>>>>>>"g.franzkowiak" <(E-Mail Removed)> (gf) wrote:

>>
>>>gf> If starts a process with popen2.popen3('myprogram') and myprogram.exe is
>>>gf> running before, I've a connection to the second process, not to the first.
>>>gf> I can find the process by name before I start a process with popen2...,
>>>gf> but how bcan I connect t this process with a pipe ?

>>
>>You have to use a named pipe.

>
>
> That would require that the application know about the named
> pipe and open it. I don't think there is any way to swap a
> pipe in for stdin/stdout once a process is running.
>

in C: freopen
 
Reply With Quote
 
Donn Cave
Guest
Posts: n/a
 
      10-29-2005
Quoth Pierre Hanser <(E-Mail Removed)>:
| Grant Edwards a écrit :
|> On 2005-10-29, Piet van Oostrum <(E-Mail Removed)> wrote:
|>>>>>>>"g.franzkowiak" <(E-Mail Removed)> (gf) wrote:
|>>
|>>>gf> If starts a process with popen2.popen3('myprogram') and myprogram.exe is
|>>>gf> running before, I've a connection to the second process, not to the first.
|>>>gf> I can find the process by name before I start a process with popen2...,
|>>>gf> but how bcan I connect t this process with a pipe ?
|>>
|>>You have to use a named pipe.
|>
|>
|> That would require that the application know about the named
|> pipe and open it. I don't think there is any way to swap a
|> pipe in for stdin/stdout once a process is running.
|>
| in C: freopen

Hello, it seems fairly clear that the stdin/stdout in question belongs
to another process, which cannot be instructed at this point to execute
freopen(). If there's a way to do this, it will be peculiar to the
platform and almost certainly not worth the effort.

Donn Cave, (E-Mail Removed)
 
Reply With Quote
 
Piet van Oostrum
Guest
Posts: n/a
 
      10-29-2005
>>>>> Grant Edwards <(E-Mail Removed)> (GE) wrote:

>GE> On 2005-10-29, Piet van Oostrum <(E-Mail Removed)> wrote:
>>>>>>>> "g.franzkowiak" <(E-Mail Removed)> (gf) wrote:
>>>

>gf> If starts a process with popen2.popen3('myprogram') and myprogram.exe is
>gf> running before, I've a connection to the second process, not to the first.
>gf> I can find the process by name before I start a process with popen2...,
>gf> but how bcan I connect t this process with a pipe ?
>>>
>>> You have to use a named pipe.


>GE> That would require that the application know about the named
>GE> pipe and open it. I don't think there is any way to swap a
>GE> pipe in for stdin/stdout once a process is running.


Sure. 'myprogram' should be designed to communicate through a named pipe,
or be called with named pipe(s) as stdin/stdout.
--
Piet van Oostrum <(E-Mail Removed)>
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4]
Private email: (E-Mail Removed)
 
Reply With Quote
 
Grant Edwards
Guest
Posts: n/a
 
      10-29-2005
On 2005-10-29, Piet van Oostrum <(E-Mail Removed)> wrote:

>>GE> That would require that the application know about the named
>>GE> pipe and open it. I don't think there is any way to swap a
>>GE> pipe in for stdin/stdout once a process is running.

>
> Sure. 'myprogram' should be designed to communicate through a
> named pipe, or be called with named pipe(s) as stdin/stdout.


That's all well and good, but it's got nothing to do with the
OP's problem: he's got a program that's already running and he
wants to write a Python program that can "attach" pipes to that
already running program's stdin/stdout. I know there's no way
to do that under Unix. IIRC, the OP is running Win32, and I'm
not quite as confident that it can't be dont under Win32, but I
don't think it can.

--
Grant Edwards grante Yow! With YOU, I can be
at MYSELF... We don't NEED
visi.com Dan Rather...
 
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
popen2.Popen3 process destruction Python 1 06-15-2004 10:35 PM
Possible problem with popen2 module A. Lloyd Flanagan Python 2 05-03-2004 02:17 PM
popen2 trouble Diez B. Roggisch Python 2 04-05-2004 12:05 PM
popen2 with large input cherico Python 2 01-29-2004 02:14 PM
popen2 Guy Python 1 08-12-2003 04:57 PM



Advertisments