PDA

View Full Version : Accessing Terminal From Cocoa?




DavidCar
Mar 28, 2005, 08:55 PM
I want to try monitoring some system statistics from a cocoa program. I don't know much about Terminal, but I'm wondering if I can issue a terminal command from cocoa and get back a string as a response. Then I can scan the string for what I want.

If I knew where to start looking in the documentation I could go from there. Thanks.

DC



HexMonkey
Mar 28, 2005, 09:48 PM
Cocoa Dev Central has a couple of useful tutorials about this. The first (http://www.cocoadevcentral.com/articles/000025.php) is an example of writing a wrapper to the wget command. The second (http://www.cocoadevcentral.com/articles/000031.php) shows how to get the output of a command (in this case, the ls command).

You might also like to look at the documentation for NSTask and NSPipe.

DavidCar
Mar 28, 2005, 11:10 PM
Cocoa Dev Central has a couple of useful tutorials about this. The first (http://www.cocoadevcentral.com/articles/000025.php) is an example of writing a wrapper to the wget command. The second (http://www.cocoadevcentral.com/articles/000031.php) shows how to get the output of a command (in this case, the ls command).

You might also like to look at the documentation for NSTask and NSPipe.

Excellent! It would have taken me a while to find those references.

Thanks.
DC