How to make a app to execute terminal command

Discussion in 'Mac Programming' started by DavidBlack, Feb 2, 2013.

  1. macrumors 6502a

    DavidBlack

    Joined:
    Jan 27, 2013
    Location:
    Somewhere In Apple's HQ ;)
    #1
    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!
     
  2. macrumors 603

    firestarter

    Joined:
    Dec 31, 2002
    Location:
    Green and pleasant land
  3. thread starter macrumors 6502a

    DavidBlack

    Joined:
    Jan 27, 2013
    Location:
    Somewhere In Apple's HQ ;)
    #3
  4. macrumors 603

    Joined:
    Aug 9, 2009
    #4
    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.
     
  5. thread starter macrumors 6502a

    DavidBlack

    Joined:
    Jan 27, 2013
    Location:
    Somewhere In Apple's HQ ;)
    #5
    Thanks for you help bro btw how do I place memory usage stats e.g how activity monitor has it.
     
  6. macrumors 603

    Joined:
    Aug 9, 2009
    #6
    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?
     
  7. thread starter macrumors 6502a

    DavidBlack

    Joined:
    Jan 27, 2013
    Location:
    Somewhere In Apple's HQ ;)
    #7
    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?
     

Share This Page