Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Feb 2, 2013, 02:00 PM   #1
DavidBlack
macrumors 6502
 
Join Date: Jan 2013
Location: Somewhere In Apple's HQ ;)
How to make a app to execute terminal command

I want to make a app that executes a terminal command with a button. Eg when I press the button I want it to purge the memory how do i do that? HELP!
DavidBlack is offline   0 Reply With Quote
Old Feb 2, 2013, 02:07 PM   #2
firestarter
macrumors Demi-God
 
firestarter's Avatar
 
Join Date: Dec 2002
Location: Green and pleasant land
Wrap a shell script with Platypus.

http://sveinbjorn.org/platypus
firestarter is offline   0 Reply With Quote
Old Feb 2, 2013, 02:34 PM   #3
DavidBlack
Thread Starter
macrumors 6502
 
Join Date: Jan 2013
Location: Somewhere In Apple's HQ ;)
Quote:
Originally Posted by firestarter View Post
Wrap a shell script with Platypus.

http://sveinbjorn.org/platypus
YEA but how to hook up the button to the code
DavidBlack is offline   0 Reply With Quote
Old Feb 2, 2013, 03:54 PM   #4
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by firestarter View Post
Wrap a shell script with Platypus.

http://sveinbjorn.org/platypus
Or if it's a single command, like 'purge', simply use this AppleScript command:
Code:
 do shell script "purge"


----------

Quote:
Originally Posted by DavidBlack View Post
YEA but how to hook up the button to the code
The same way you'd do it in any other AppleScript. If you're looking for a tutorial on writing AppleScript and hooking it up to buttons, you should search for that using a search engine like google.

If all you want to do is run the 'purge' command, you don't need a button for that. Enter the command I posted above. Save your AppleScript as an application. To purge memory, launch the application. Every time the application is launched, it purges memory. No button needed/

If you want to do other things, like present a dialog, there are AppleScript commands for that. Google search terms: applescript dialog.

If you want a complete window, with multiple buttons, one of which purges memory, and other buttons that do other things, look for a tutorial on making windowed applications with buttons in AppleScript. Everything other than do shell script "purge" will be common to all such AppleScript apps.
chown33 is offline   2 Reply With Quote
Old Feb 2, 2013, 09:37 PM   #5
DavidBlack
Thread Starter
macrumors 6502
 
Join Date: Jan 2013
Location: Somewhere In Apple's HQ ;)
Quote:
Originally Posted by chown33 View Post
Or if it's a single command, like 'purge', simply use this AppleScript command:
Code:
 do shell script "purge"


----------



The same way you'd do it in any other AppleScript. If you're looking for a tutorial on writing AppleScript and hooking it up to buttons, you should search for that using a search engine like google.

If all you want to do is run the 'purge' command, you don't need a button for that. Enter the command I posted above. Save your AppleScript as an application. To purge memory, launch the application. Every time the application is launched, it purges memory. No button needed/

If you want to do other things, like present a dialog, there are AppleScript commands for that. Google search terms: applescript dialog.

If you want a complete window, with multiple buttons, one of which purges memory, and other buttons that do other things, look for a tutorial on making windowed applications with buttons in AppleScript. Everything other than do shell script "purge" will be common to all such AppleScript apps.
Thanks for you help bro btw how do I place memory usage stats e.g how activity monitor has it.
DavidBlack is offline   0 Reply With Quote
Old Feb 3, 2013, 05:38 PM   #6
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by DavidBlack View Post
Thanks for you help bro btw how do I place memory usage stats e.g how activity monitor has it.
I don't understand what you want.

Are you asking how to get memory usage statistics? Or are you asking how to display statistics in a list that looks similar to Activity Monitor?

Are you really trying to write a replacement for Activity Monitor using AppleScript? If so, why?
chown33 is offline   0 Reply With Quote
Old Feb 3, 2013, 05:41 PM   #7
DavidBlack
Thread Starter
macrumors 6502
 
Join Date: Jan 2013
Location: Somewhere In Apple's HQ ;)
Quote:
Originally Posted by chown33 View Post
I don't understand what you want.

Are you asking how to get memory usage statistics? Or are you asking how to display statistics in a list that looks similar to Activity Monitor?

Are you really trying to write a replacement for Activity Monitor using AppleScript? If so, why?
No I am making a free memory app. And I want to get the stats in activity monitor in the app the free memory pie chart how do I get that done?
DavidBlack is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Terminal command andynewfriends Mac Basics and Help 0 Jun 11, 2013 02:25 PM
Delay command in Terminal Darundal Mac Programming 4 May 13, 2013 06:02 AM
How do I make Bash 4.2 the default Terminal.app shell? printz OS X 3 May 6, 2013 01:23 AM
Need command in terminal chadteetzen OS X 1 Jun 8, 2012 11:55 PM

Forum Jump

All times are GMT -5. The time now is 10:45 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC