DirectNET

Data Center Management Solutions including UPS Systems, Data Center Cooling, KVM over IP & IP Power Strips, Server Racks and Server Rack accessories; KVM Switches and KVM Extenders; Rackmount Monitors and Rackmount Keyboards.


NAVIGATION
Home
Store
INSIDE MAC
Television Shows
Broadcast Shows
Daily News Shows
Special Shows
EVENTS
DAILY TIPS
Design
Mac OS X
Mac OS X UNIX
COMMUNITY
Forums
Surveys
NEWS
Current
Press
Archive
FEATURES
Editorial
Dr. Mac
Reviews
Reader Reports
RESOURCES
FAQ
Documentation
Learning Center
MAN pages
Glossary
Tutorials
Tips
Links

OUR PARTNERS

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

Copyright © 2000-2008 Inside Mac Media, Inc. All rights reserved.
Apple assumes no responsibility with regard to the selection, performance, or use of the products or services. All understandings, agreements, or warranties, if any, take place directly between the vendors and prospective users.
Apple, the Apple logo, Mac, PowerMac G4, PowerMac G5, Xserve, Xserve RAID, PowerBook, iBook, Airport, AirPort Extreme, iMac, eMac, iLife, iMovie, iCal, iPhoto, iTunes, QuickTime, FireWire, iPod, iSight, AppleWorks, Macintosh, Jaguar, Panther, Mac OS, Mac OS X and Mac OS X Server are trademarks of Apple Computer, Inc.