Re: Bundling AppleScripts with shell scripts
Re: Bundling AppleScripts with shell scripts
- Subject: Re: Bundling AppleScripts with shell scripts
- From: John Delacour <email@hidden>
- Date: Mon, 1 Sep 2003 20:59:34 +0100
- Mac-eudora-version: 6.1a1
At 10:56 am -0600 1/9/03, Doug McNutt wrote:
Andrew Trevorrow has contributed a couple of executables, written in
C, which convert line ends in place without messing with type and
creator. <ftp://ftp.trevorrow.com/m2u-u2m.sit>
I would like to provide a drag and drop interface using AppleScript.
The code below works fine on my system but how can I send it off to
users who are not Terminal savvy? Is there a standard procedure I
can use for getting the two shell scripts in a politically correct
place with matching specifications in the AppleScript? How about
setting the permission and execute bits for the binaries? I shudder
at the prospect of writing instructions. Is it easier to write an
install script? Would administrator privilege be required to install
the binaries in the "correct" location for access by any user?
The whole thing could be done automatically as in the example below.
I would doStuff with a single argument list.
property dir : "/Users/Shared/Projects/LineEnds/"
property exe : "u2m.pl" -- change to m2u for other way
-- C R E A T E E X E
do shell script "mkdir -p -m 755 " & dir & "; perl -e '
$exe = q~" & dir & exe & "~;
open EXE, qq~>$exe~ or die $!;
$script = q |#!/usr/bin/perl" & (ASCII character 10) & "
for (@ARGV) {++$i; print qq~$i\\. $_$/~ ; }|;
print EXE $script'"
--
tell application "Finder"
set aARGV to space
repeat with f in (get selection)
set f to f as alias
set aARGV to aARGV & quoted form of POSIX path of f & space
end repeat
end tell
doStuff(aARGV)
-- R U N E X E
on doStuff(aARGV)
set _exe to quoted form of (dir & exe)
do shell script "chmod 755 " & _exe & ";
." & _exe & aARGV -- note the dot
end doStuff
JD
_______________
*** begin script ***
property basedir : "$HOME/Projects/LineEnds/"
property executable : "u2m" -- change to m2u for other way
-- This section runs while in the script editor.
-- Starting point is selection in the finder.
tell application "Finder"
set argList to selection
repeat with theTarget in argList
set bbb to theTarget as alias
set thePath to quoted form of POSIX path of bbb
my doStuff(thePath)
end repeat
end tell
-- This happens when icons are dropped onto the script in Applet form.
-- Note that finder resolves any aliases even though it delivers
alis's in arglist.
on open (argList)
tell application "Finder"
repeat with theAlias in argList
set thePath to quoted form of POSIX path of theAlias
my doStuff(thePath)
end repeat
beep
end tell
end open
on doStuff(aPath)
do shell script basedir & executable & space & aPath
end doStuff
*** end script ***
--
Applescript syntax is like English spelling:
Roughly, but not thoroughly, thought through.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.