Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > executing a process and capture its output

executing a process and capture its output
Thread Tools
djcornell
Fresh-Faced Recruit
Join Date: Apr 2002
Location: vancouver
Status: Offline
Reply With Quote
Apr 22, 2002, 07:40 PM
 
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.
     
kamprath
Junior Member
Join Date: Apr 2000
Location: San Francisco, CA
Status: Offline
Reply With Quote
Apr 22, 2002, 07:52 PM
 
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
     
djcornell  (op)
Fresh-Faced Recruit
Join Date: Apr 2002
Location: vancouver
Status: Offline
Reply With Quote
Apr 22, 2002, 08:05 PM
 
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.
     
kamprath
Junior Member
Join Date: Apr 2000
Location: San Francisco, CA
Status: Offline
Reply With Quote
Apr 23, 2002, 12:16 AM
 
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
     
djcornell  (op)
Fresh-Faced Recruit
Join Date: Apr 2002
Location: vancouver
Status: Offline
Reply With Quote
Apr 23, 2002, 12:35 PM
 
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?
     
Smircle
Forum Regular
Join Date: Feb 2001
Location: Berlin, .de
Status: Offline
Reply With Quote
Apr 23, 2002, 01:50 PM
 
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.
     
djcornell  (op)
Fresh-Faced Recruit
Join Date: Apr 2002
Location: vancouver
Status: Offline
Reply With Quote
Apr 23, 2002, 02:14 PM
 
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??
     
kamprath
Junior Member
Join Date: Apr 2000
Location: San Francisco, CA
Status: Offline
Reply With Quote
Apr 23, 2002, 05:07 PM
 
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 Links
Forum 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
Top
Privacy Policy
All times are GMT -4. The time now is 07:38 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,