Re: Passing dropped items to shell script
Re: Passing dropped items to shell script
- Subject: Re: Passing dropped items to shell script
- From: Roger Howard <email@hidden>
- Date: Thu, 14 May 2009 15:20:23 -0700
On Thu, 14 May 2009 14:19:28 -0700, Marconi <email@hidden> wrote:
> on open dropped_items
> repeat with i from 1 to the count of dropped_items
> set this_item to (item i of dropped_items)
> set thepath to POSIX path of this_item
> set myMessage to (do shell script "/path/to/perl/script.pl
\"thepath\"")
> display dialog myMessage
> end repeat
> end open
>
> I get no errors (myMessage is "") but the script does not do its
> thing. If I pass the file in terminal. the script works. So... I'm
> probably not passing it properly.
It's a problem with your do shell script command - try the following
instead (there are two fixes in this):
set myMessage to (do shell script "/path/to/perl/script.pl " & quoted
form of thepath)
The first problem was you just placed "thepath" into a string, you didn't
actually get the value of that variable. In AppleScript the best way to do
that is to concatenate strings and variables - there's no way (that I know
of) to include variables inline in strings as in some other languages.
Second, not necessarily a problem, but it's safer to use a built-in method
to quote your paths, and makes for easier to read code too.
In the future I'd recommend trying a simple debugging technique to make
sure the command string you're passing to do shell script is actually what
you expect - either use the built-in AppleScript "log" command, or throw up
a dialog with the value of that string. For instance:
display dialog "/path/to/perl/script.pl \"thepath\""
Would have shown you that the string wasn't what you were looking for..
> Also, is it possible to put the perl script in the application bundle
> and call it there?
Yep - try it! It's just another file in another directory (app bundles are
just directories).
Best,
R
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden