Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > AppleScript drag-and-drop application that performs terminal command?

AppleScript drag-and-drop application that performs terminal command?
Thread Tools
Senior User
Join Date: Feb 2004
Location: Lost in a "plus" world
Status: Offline
Reply With Quote
Apr 6, 2004, 10:03 AM
 
I'd like to see about making an AppleScript that, when files are dragged on to it, performs a terminal command on those files automagically.

Is this possible, and if so, where in the world do I go for information / example code on putting this together?
     
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status: Offline
Reply With Quote
Apr 6, 2004, 10:09 AM
 
Originally posted by memory-minus:
I'd like to see about making an AppleScript that, when files are dragged on to it, performs a terminal command on those files automagically.

Is this possible, and if so, where in the world do I go for information / example code on putting this together?
Use AppleScript Studio. The shell script itself is easy -- just call "do shell script" from within AppleScript.
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
     
Senior User
Join Date: Oct 2000
Location: Midwest
Status: Offline
Reply With Quote
Apr 6, 2004, 12:55 PM
 
I agree with Arkham_c that in the end you will use Studio if you use 'do shell script' extensively. To experiment a bit before jumping into Studio, here is an example that may get you started:

--drop small text file on the script icon
-- save as application, we are creating a droplet.


on open _file
set filePosixPath to POSIX path of _file
set theContents to do shell script "cat " & filePosixPath
display dialog theContents

Display dialog has a limitation on characters displayed, so the file needs to be small. You could save the result to a file, you can pipe your stderr to a file- lots of possibilities. Here is the Technical Note on Apple's site that begins to describe 'do shell script'. TN2065

HTH
Craig
     
JNI
Forum Regular
Join Date: Oct 2002
Location: Left Coast
Status: Offline
Reply With Quote
Apr 6, 2004, 02:08 PM
 
Originally posted by memory-minus:
I'd like to see about making an AppleScript that, when files are dragged on to it, performs a terminal command on those files automagically.

Is this possible, and if so, where in the world do I go for information / example code on putting this together?
There's a Drag and Drop example in /Developer/Examples/AppleScript Studio folder. You could either modify it (make a private copy first so you still have the original) or you could use it as a guide to create your own app after starting with an AppleScript Studio template project in Xcode.
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Apr 6, 2004, 02:26 PM
 
     
JNI
Forum Regular
Join Date: Oct 2002
Location: Left Coast
Status: Offline
Reply With Quote
Apr 6, 2004, 02:49 PM
 
Originally posted by Angus_D:
Why use AppleScript at all?
http://www.mit.edu/people/wsanchez/s...Script-0.5.dmg
I agree that ASS is overkill if all you want to do is the same operation to all files dropped onto the applet and don't need any significant user interaction. But if you want to do any kind of medium to complex interaction on the dropped items, show status, allow for canceling during lengthy processing or various other GUI type things, then ASS is a good way to do it.

(I saw your smiley Angus_D, but I figured I'd answer the question anyway so that the poster would see why they might want to use ASS.)
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:06 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2