• Mac OS X,  Mac OS X Server,  Mac Security,  Mass Deployment

    Scripting Volume Control in OS X

    I’ve always found the easiest way to script the volume of an OS X computer (and when I say volume I mean sound level, not a logical volume created from partitioning a hard drive – but I have articles for scripting those as well) is using the osascript command to invoke an Applescript command that sets the volume to zero. To put some syntax around this: osascript -e "set volume 0"

  • Mac OS X,  Mac Security

    Mac OS X: Invoke a Command w/ ScreenSaver

    Found this nice little tool called ScriptSaver today. Basically, when the screen saver in Mac OS X is activated and/or deactivated it will run an AppleScript. The AppleScript can call a shell script or you can write an application in AppleScript and choose it from within the script. The developer has also made some sample AppleScripts available for use with ScriptSaver. For my purpose I just wanted to kill Safari, so I used an AppleScript of: tell application "Safari" quit saving no end tell However, I could have just as easily have used

  • Mac OS X,  Mac OS X Server

    Invoke ScreenSaver in Mac OS X with a Script

    While troubleshooting some issues with a Screen Saver that just wouldn’t fire up. Even when you told the ScreenSaver to open (timed or via Expose) it wouldn’t work. Given the security implications for the given environment having a Screen Saver invoked automatically and manually are both requirements. So I found how to open it from the shell. From the /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app/Contents/MacOS working directory simply do: ./ScreenSaverEngine The Screen Saver opened from the shell so I figured I would try it from an AppleScript, so isolated the application id to com.apple.ScreenSaver.Engine and launched it manually: osascript -e ‘tell application id “com.apple.ScreenSaver.Engine” to launch’ This didn’t work.  Replaced the ScreenSaver.Framework (located in /System/Library/Frameworks) with…

  • Mac OS X Server,  Mass Deployment

    Troubleshooting Automounting with AppleScript

    Troubleshooting automounts can be a particular pain at times. Beyond verifying that you can manually mount a directory and that the automount shows up properly in the directory service, there is another little trick that I’ll occasionally do, which is to set an Applescript to load the mount point at some time during the login process (or more specifically at different times in order to further isolate). The quick and dirty script I use is: set MyVolume to “afp://username:password@my.server.com/mysharepoint” tell application “Finder”      activate      mount volume MyVolume end tell Obviously you’ll have a different volume name you wish to mount the share as and a different user,…

  • Mac OS X,  Mac OS X Server

    AppleScript and Paths

    When you’re using Applescript to script some events, you’ll need to use a path. For example, if you’re opening an application, you can use the launch application option. When you do so, you’ll need to swap out slashes (/) with colons (:). So, let’s look at Mail.app. The following command in bash would open Mail: open /Applications/Mail.app But to run in Applescript, use the following command: launch application ":Applications:TextEdit.app" or tell application ":Applications:TextEdit.app" to launch Enjoy