Apple Script Question

Discussion in 'Mac Apps and Mac App Store' started by Diatribe, May 16, 2004.

  1. Diatribe macrumors 601


    Jan 8, 2004
    Back in the motherland

    I was just wondering how you build a script that incorporates the execution of a Terminal command line. I'm just a total newb when it comes to stuff like this.
    Any help is highly appreciated... :D
  2. sageenos macrumors member

    Jan 5, 2002
    South Carolina
    tell application "Terminal"
    do script "echo Hello World!"
    end tell

    -- use the do script command with a string value
  3. Diatribe thread starter macrumors 601


    Jan 8, 2004
    Back in the motherland
    Thanks a lot. I works flawlessly. :D
    Just one more question. How do you let the script close the Terminal window AFTER the process is done, or the Terminal itself for that matter. (Haven't figured out yet which I'd prefer)
  4. MarkDouma macrumors newbie

    May 16, 2004
    Grand Rapids, Michigan, USA
    Actually, you might say there are 2 ways of accessing the shell from AppleScript.

    'do script' and using the Terminal application to present you with the running shell command is one option.

    The other option is to use the 'do shell script' of Standard Additions, which works for OS X 10.1.2 or later.

    The following script is an example of a 'do shell script':

    If you're using Panther, the link should open up in Script Editor, then just press the green "Play" button and enter your password when prompted.

    (Note regarding this particular script:
    I recently used the "Restore" tab of Panther's Disk Utility (which uses the 'asr' Apple Software Restore tool) to clone the 7 partitions of one 80 GB to another 80 GB. The end result left many files and folders on my user partition which were owned by root, and which I didn't have access to, until I fixed the permissions on them myself.)

    You can use the following AppleScript to check for any files in your home folder that have ownership that isn't your own. (Note, I'm using 'sudo'—that's what 'with administrator privileges' equates to—to be able to search inside of any root-owned folders that might ordinarily cause access denied errors.)

    Also, the following page is a must read:

    Hope this helps....
    [This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

Share This Page