Re: osascript shell commands using AppleScript
Re: osascript shell commands using AppleScript
- Subject: Re: osascript shell commands using AppleScript
- From: Bill Cheeseman <email@hidden>
- Date: Tue, 24 Jun 2008 17:53:24 -0400
- Thread-topic: osascript shell commands using AppleScript
on 2008-06-24 4:40 PM, Mark J. Reed at email@hidden wrote:
>> But how do I capture shell variables like $1 and $2 when doing this? I'm
>> thinking of using AppleScript this way in a PackageMaker 3 shell script.
>
> The shell is not involved in this process; just osascript and
> AppleScript. $1 etc are the syntax for getting at the command line
> arguments within a shell script. If you're asking how you access
> command line arguments within an AppleScript invoked this way, it's
> the same as if it were an applet: supply an on run handler.
>
> $ cat >hello.as <<EOF
> #!/usr/bin/osascript
> on run(args)
> return "Hello, " & first item of args as string & "!"
> end
> EOF
> $ chmod 0755 hello.as
> $ ./hello.as world
> Hello, world!
I'm not quite sure how to translate that into an osascript shell script file
that I might install as an installer script in PackageMaker 3.
Based on your model, I'm thinking the script file itself would look like
this:
#!/usr/bin/osascript
on run(args)
return "Hello, " & first item of args as string & "!"
end
Then when Installer runs the script during installation, the call to 'first
item of args' would return the value of $1. Is that your expectation?
But then how do I get the environment variables that PackageMaker/Installer
provide?
What I'm doing right now is using a bash script file. It works perfectly
well, but I'm curious how to convert it to an osascript shell script that
has the same access to the parameters and environment variables. Here's my
bash script:
#!/usr/bin/env bash
installedPath="\"$2\""
osascript <<END
tell application "Finder" to update POSIX file $installedPath
END
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
www.quecheesoftware.com
PreFab Software - www.prefabsoftware.com
_______________________________________________
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