PDA

View Full Version : Terminal Command Script




chisasba
Apr 21, 2012, 02:01 PM
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.



kryten2
Apr 21, 2012, 07:30 PM
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 :

Once a user has been authenticated, a timestamp is updated and the user may then use sudo without a password for a short period of time (5 minutes unless overridden in sudoers).

chisasba
Apr 22, 2012, 02:13 AM
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 :

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.

macsmurf
Apr 22, 2012, 02:35 AM
http://stackoverflow.com/questions/1517183/is-there-any-graphical-sudo-for-mac-os-x

kryten2
Apr 22, 2012, 12:34 PM
how do I get it to enter my password for me?

No tell application Terminal block needed for these two lines :

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

chisasba
Apr 22, 2012, 12:43 PM
No tell application Terminal block needed for these two lines :

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

Cool thank you, that worked perfectly.