Re: osascript shell commands using AppleScript
Re: osascript shell commands using AppleScript
- Subject: Re: osascript shell commands using AppleScript
- From: "Mark J. Reed" <email@hidden>
- Date: Tue, 24 Jun 2008 16:40:46 -0400
On Tue, Jun 24, 2008 at 3:58 PM, Bill Cheeseman <email@hidden> wrote:
> In Leopard, we are told that AppleScript allows use of "#" as an alternative
> to "--" as a comment-to-end-of-line token, and that as a result shell
> commands can be written using straight AppleScript by including the comment
> #!usr/bin/osascript at the beginning and setting the file's execute bit.
>
> Sure enough, it works.
>
> 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!
--
Mark J. Reed <email@hidden>
_______________________________________________
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