Terminal Command Script

Discussion in 'Mac Programming' started by chisasba, Apr 21, 2012.

  1. macrumors member

    Joined:
    Mar 2, 2012
    #1
    Basically I'm trying to make it so I can run some commands to hide things using terminal without having to manually enter each one. I went to AppleScript Editor to try this but having issues. I've never made one before so I have no idea what I'm doing wrong.

    Here is what I got so far:

    activate application "Terminal"
    do script "sudo chflags hidden /Applications/Utilities/Bluetooth\ File\ Exchange.app" (**It tells me syntax error here and doesn't continue)
    delay 1
    do script "password" (**For my password)
    delay 1
    do script "sudo chflags hidden /Applications/Utilities/Expose.app"
    delay 1
    end tell

    Thanks for any help.
     
  2. macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #2
    Code:
    tell application "Terminal"
    	activate
    	do script "sudo chflags hidden /Applications/Utilities/Bluetooth\\ File\\ Exchange.app" in window 1
    	delay 1
    	do script "chflags hidden /Applications/Utilities/Expose.app" in window 1
    end tell
    Second sudo not needed. From the man page of sudo :

     
  3. thread starter macrumors member

    Joined:
    Mar 2, 2012
    #3
    Ok thanks I got it that part but how do I get it to enter my password for me?
    I tried adding 'do script "password" in window 1' after the first delay but no luck.
     
  4. macrumors 65816

    macsmurf

    Joined:
    Aug 3, 2007
  5. macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #5
    No tell application Terminal block needed for these two lines :

    Code:
    do shell script "chflags hidden /Applications/Utilities/Bluetooth\\ File\\ Exchange.app" user name "yourusername" password "password" with administrator privileges
    do shell script "chflags hidden /Applications/Utilities/Expose.app" user name "yourusername" password "password" with administrator privileges
     
  6. thread starter macrumors member

    Joined:
    Mar 2, 2012
    #6
    Cool thank you, that worked perfectly.
     

Share This Page