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 > How to run shell scripts from cocoa

How to run shell scripts from cocoa
Thread Tools
Mac Elite
Join Date: Oct 2000
Location: Seattle
Status: Offline
Reply With Quote
Dec 21, 2000, 01:09 AM
 
How do I run shell scripts from a cocoa app?

I would like to do a simple app that is a front end to apache. it would just have buttons that send commands to the shell like 'apachectl stop'

I guess I'll also need a way to get root access like the lock icon password function in NetInfoManager.

Can someone point me to example code or documentation?

Source code for a simple aqua terminal would be helpful too.

thanks
You can take the dude out of So Cal, but you can't take the dude outta the dude, dude!
     
Mac Enthusiast
Join Date: Oct 2000
Location: Toronto
Status: Offline
Reply With Quote
Dec 22, 2000, 07:32 AM
 
Hi Gavin, I think Apple is already creating a front-end to apache (more than just the start/stop/directory thing we have now). I think this is posted in one of the forums.

That was just a side note, I would also be interested in the answer to your question as well.

[This message has been edited by anothermacguy (edited 12-22-2000).]
     
Fresh-Faced Recruit
Join Date: Oct 2000
Location: Arlington, VA
Status: Offline
Reply With Quote
Dec 22, 2000, 01:19 PM
 
Eric Peyton (Epicware) wrote a WebGrabber, a wrapper for pavuk, a fairly complex command-line utility. He was gracious enough to GPL his work. You can find source and binaries at:
http://www.epicware.com/webgrabber.html

I know of a couple of other examples which escape me at the moment. If I find them, I'll edit this post.

     
Gavin  (op)
Mac Elite
Join Date: Oct 2000
Location: Seattle
Status: Offline
Reply With Quote
Dec 22, 2000, 09:21 PM
 
Thanks.

WebGrabber is great. it has examples of both sending messages to command line utilities AND displaying the resutls in a textbox (another thing I was looking for)

I'm just doing a simple GUI for apachectl as a learning tool. I thought it would be easy to do as it only has 6 items and there is no interaction needed. (and I've been debugging mod_rewrite rules and I thought a simple restart button would be nifty)

I have it mostly working, it sends all the commands but you have to log in as root and and some of the responses go to the system consle not my textfield.

I am amazed at how easy it is to use cocoa. This is the first thing I have done in OBJ-C / cocoa and I did it in just 4 hours (including learning how) - VERY cool.

the next step is to add user auth along the lines of the sys prefs pannel.
You can take the dude out of So Cal, but you can't take the dude outta the dude, dude!
     
Fresh-Faced Recruit
Join Date: Oct 2000
Location: Arlington, VA
Status: Offline
Reply With Quote
Dec 22, 2000, 09:53 PM
 
Cocoa is definitely cool. I have been researching similar things and have found the Omni Group lists to be extremely helpful. I have not yet joined, but regularly go through the archives. (I'll soon be changing ISPs and am trying to get all my correspondents to send webmail-- don't want to read a high volume list via a browser!!) There was a code sample this month showing how to do the auth panel as well:

http://www.omnigroup.com/mailman/arc...er/006475.html

Good luck!
     
Gavin  (op)
Mac Elite
Join Date: Oct 2000
Location: Seattle
Status: Offline
Reply With Quote
Dec 24, 2000, 04:14 AM
 
Well, I finished it.

It works great. 'Apache Control' does the following amazing things:

It starts apache

It stops Apache

One Button (patent pending) gracefull restart for easy config file debugging

And if you have 'lynx' it will give you 2, count 'em, two types of status reports!

From a programming point of view it does some neat things:

It gets your root password just like "System Preferences" using the built in netInfo panel. It allows you to execute commmands as root. it takes info returned and puts it in a text box. and it uses several IB tricks for user feedback. All this uses uses examples of code I found from several sources so you don't have to track it all down if you are learning this stuff.

It's a complete interface to a nifty UNIX command line tool and it only took me two days, about half of that time was spent online getting help and learning how to do it. I think this is good news for people worring about the command line ruining the mac way of life. If I can do this over a weekend for fun then GUI front ends for lots of CL tools should pop up soon.


I'll put it on a web site for downloading, source and all, for anyone who wants to take a look.

I'll post a link here when it's ready.

G
You can take the dude out of So Cal, but you can't take the dude outta the dude, dude!
     
Dedicated MacNNer
Join Date: Nov 2000
Status: Offline
Reply With Quote
Dec 31, 2000, 12:37 PM
 
Most excellent. I'd be quite interested in seeing your source. I've packaged up The Internet Junkbuster and wrote the necessary StartupItems. I'm working on a GUI configuration program, but superuser privileges were going to be a problem. I had intended to do something involving the SETUID bit and password verification with netinfo. Hopefully you have a better solution. If I can get root from within a Cocoa app, I suppose I could write a better installer than the install.sh script I currently have. I'm waiting on a response regarding a license question from the authors of The Internet Junkbuster. As soon as they respond, I'll try and get something out on the web.
     
Gavin  (op)
Mac Elite
Join Date: Oct 2000
Location: Seattle
Status: Offline
Reply With Quote
Jan 1, 2001, 01:05 AM
 
OK, I finally got off my butt and put Apache Control on line. You can get the source code and a pre-compiled binary.
http://miltonshole.thespacemonkey.co...hecontrol.html

You can take the dude out of So Cal, but you can't take the dude outta the dude, dude!
     
Dedicated MacNNer
Join Date: Nov 2000
Status: Offline
Reply With Quote
Jan 1, 2001, 08:52 AM
 
Thanks Gavin. I'm downloading your stuff right now.
     
Banned
Join Date: Aug 2006
Status: Offline
Reply With Quote
Jun 4, 2006, 06:01 AM
 
Hi All.

I know this thread is really old now, but I came across this thread while googling. Is there any possiblility you could repost your code, or email me: giles[dot]williams [at] gmail[dot]com

Thanks.
     
   
Thread Tools
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 11:21 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2