|
|
executing a process and capture its output
|
|
|
|
Fresh-Faced Recruit
Join Date: Apr 2002
Location: vancouver
Status:
Offline
|
|
hi,
Just wondering if anyone could point me to website that has an example of spawning a terminal process and piping its output to a textbox window in a carbon application.
Thanks.
|
|
|
|
|
|
|
|
|
Junior Member
Join Date: Apr 2000
Location: San Francisco, CA
Status:
Offline
|
|
Originally posted by djcornell:
<STRONG>hi,
Just wondering if anyone could point me to website that has an example of spawning a terminal process and piping its output to a textbox window in a carbon application.
Thanks.</STRONG>
No need for a website.
man popen
|
--
Michael F. Kamprath
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Apr 2002
Location: vancouver
Status:
Offline
|
|
Originally posted by kamprath:
<STRONG>
No need for a website.
man popen</STRONG>
I think i made a mistake by saying a terminal process, i'm actually trying to make a carbon gui for an app that i ported to osx that currently only runs from the terminal. So I would like the gui to be able to start and stop the app as well as capture its output.
|
|
|
|
|
|
|
|
|
Junior Member
Join Date: Apr 2000
Location: San Francisco, CA
Status:
Offline
|
|
Originally posted by djcornell:
<STRONG>
I think i made a mistake by saying a terminal process, i'm actually trying to make a carbon gui for an app that i ported to osx that currently only runs from the terminal. So I would like the gui to be able to start and stop the app as well as capture its output.</STRONG>
Like I said:
man popen
Read it closely, and realize that UNIX man pages have more than just shell comands. I leave the rest as an excercise to the reader.
Michael Kamprath
|
--
Michael F. Kamprath
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Apr 2002
Location: vancouver
Status:
Offline
|
|
Originally posted by kamprath:
<STRONG>
Like I said:
man popen
Read it closely, and realize that UNIX man pages have more than just shell comands. I leave the rest as an excercise to the reader.
Michael Kamprath</STRONG>
Thanks for your help micheal, I have tried replacing my fork
with popen but my program seems to hang, is there a way for
my program to continually grab output from the app its running
and close it when a user clicks a button?
|
|
|
|
|
|
|
|
|
Forum Regular
Join Date: Feb 2001
Location: Berlin, .de
Status:
Offline
|
|
Originally posted by djcornell:
Just wondering if anyone could point me to website that has an example of spawning a terminal process and piping its output to a textbox window in a carbon application.
Go to apples developer website and look for a example called "Moriarity carbon". There is also a Cocoa example by that name, but I found the Carbon one very useful.
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Apr 2002
Location: vancouver
Status:
Offline
|
|
Originally posted by Smircle:
<STRONG>Originally posted by djcornell:
Go to apples developer website and look for a example called "Moriarity carbon". There is also a Cocoa example by that name, but I found the Carbon one very useful.</STRONG>
Thanks, i think this is what im looking for, strange i can only find the cocoa version. do you have the link to the carbon version still hangin around??
|
|
|
|
|
|
|
|
|
Junior Member
Join Date: Apr 2000
Location: San Francisco, CA
Status:
Offline
|
|
Originally posted by djcornell:
<STRONG>
Thanks for your help micheal, I have tried replacing my fork
with popen but my program seems to hang, is there a way for
my program to continually grab output from the app its running
and close it when a user clicks a button?</STRONG>
Don't try to read the entire results stream all at once. Read only a chunck at a time. Place your results stream reading code in an event loop timer so that in between stream reads, your program is able to handle carbon events. Since your popen'ed process is it's own process, this allows for your carbon application to no have to wait until the forked process is completed before the carbon app can return ro the event loop.
Michael Kamprath
|
--
Michael F. Kamprath
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|