OSXFAQ Reader Tips 
Jaguar - AppleScript and UNIX.
OSXFAQ Reader Tip By Jim Williamson
Here's a very customizable and easy time-saving tip for reaching in and
using those powerful UNIX tools without having to remember lengthy strings
of commands.
The tip involves wrapping AppleScript around Terminal commands, so you'll
need to know a little AppleScript and a little UNIX. Here's how:
1) Install Apple's Script Menu
http://www.apple.com/applescript/script_menu/
2) Locate the Scripts folder (/Library/Scripts) and make a folder inside the
Scripts folder to hold your customized scripts. This folder will now be
available as a choice in the Script Menu pull-down choices.
3) Open the Terminal and run a command. Once you see that the command runs
properly and returns what you are seeking, copy that command to the
clipboard.
4) Create a new script in Script Editor. Paste the copied command inside the
following AppleScript:
try
activate
tell application "Terminal"
activate
do script with command "PASTE-TERMINAL-COMMAND-HERE"
end tell
on error error_message
beep
display dialog error_message buttons {"OK} default button 1
end try
5) Save the AppleScript as a compiled script inside your customized folder.
In order to run it, simply select the script from the Script Menu pull-down
menu.
So, for example, I might wish to view my various networking ports, so I run:
try
activate
tell application "Terminal"
activate
do script with command "ifconfig -au"
end tell
on error error_message
beep
display dialog error_message buttons {"OK} default button 1
end try
You can also use this trick to create scripts for a variety of non-Terminal
tasks: I've created AppleScripts to check to see if Classic is running; to
open oft-used but buried folders (like the Script folder!); to open a group
of related applications with a single bound (e.g., Dreamweaver, Photoshop,
and BBEdit for web work) etc.
Enjoy!
If you would like to see your tip here send it to us at contribute@osxfaq.com, You could be famous to!!
|