Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

chisasba

macrumors member
Original poster
Mar 2, 2012
31
0
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.
 
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 :

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).
 
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 :

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.
 
how do I get it to enter my password for me?

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
 
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

Cool thank you, that worked perfectly.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.