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 > AppleScript: possible to run shell scripts without opening Terminal.app??

AppleScript: possible to run shell scripts without opening Terminal.app??
Thread Tools
Dedicated MacNNer
Join Date: Feb 2001
Location: Huddersfield, UK
Status: Offline
Reply With Quote
May 5, 2002, 07:23 AM
 
I'm in the middle of writing an AppleScript script that can extract various bits of information from the wealth of information provided by such terminal commands as ps, df, vm_stat, uname, hostinfo etc...

Because the script has to access the shell regularly, I have been wondering if this is possible without opening a Terminal window every time I need to get some info...

I don't have AppleScript Studio (using a 56 kbps modem)... but if someone could shed some light on the matter, I'd be most grateful.

Also, could someone comment on other possible ways of accessing the shell, be it using Obj-C, C++, C, Java or whatever. I'd like to know if there was a better way to do this (I'm can't program in any of the mentioned languages, but I figure that if I just want to extract information, if can't be that difficult, right?? )

Cheers, Richard
PM G4 DP 500 MHz, 768 Mb, DVD-ROM, 85 Gb, Mac OS X 10.3.9
PB G4 1.25 GHz, 512 Mb, DVD-R, 80 Gb, Mac OS X 10.4
     
Forum Regular
Join Date: Jan 2002
Location: New York
Status: Offline
Reply With Quote
May 5, 2002, 07:50 AM
 
Try this:

do shell script "blah"

if you want to do it as an admin do:

do shell script "blah" password "cookie" with administrator privileges

Hope that helps!
     
Mac Enthusiast
Join Date: Apr 2001
Location: 127.0.0.1
Status: Offline
Reply With Quote
May 5, 2002, 01:16 PM
 
I've attempted to put together a simple AppleScript which will allow me to start/stop my local MySQL server from a GUI. I managed to find the "do shell script" routine ksuther mentioned above, and this approach works great for stopping the server. However, starting the server requires that mysqld be fired off as a background process, and AppleScript sits there waiting for the process to return. Is there any way to get my script to "detach" itself from this background process so it doesn't hang waiting?
     
Dedicated MacNNer
Join Date: Mar 2001
Location: Pittsburgh, PA USA
Status: Offline
Reply With Quote
May 5, 2002, 03:08 PM
 
Excellent - I came here planning to ask "how do I run a shell script as root from an AppleScript?" and ran straight into the answer. Thanks - now I have dock items that will let me start and stop IP forwarding my PPP connection to another box.

Danke,
Jeff
     
Richyfp  (op)
Dedicated MacNNer
Join Date: Feb 2001
Location: Huddersfield, UK
Status: Offline
Reply With Quote
May 6, 2002, 04:53 AM
 
Thanks very much for your help, ksuther! And I'm glad that this thread is helping other people too...

Thanks again,
Richard
PM G4 DP 500 MHz, 768 Mb, DVD-ROM, 85 Gb, Mac OS X 10.3.9
PB G4 1.25 GHz, 512 Mb, DVD-R, 80 Gb, Mac OS X 10.4
     
   
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 02:54 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