Re: Pass Finder Selection to Shell Argument
Re: Pass Finder Selection to Shell Argument
- Subject: Re: Pass Finder Selection to Shell Argument
- From: "Mark J. Reed" <email@hidden>
- Date: Thu, 6 Sep 2007 18:38:36 -0400
That's all pure shell. From the for through the done it would work in
a Terminal window. I suggest you poke atround online for shell
scripting tutorials.
`for f in "$@"; do' is essentially shell for `repeat with f in
parameters', assuming parameters is a list containing the passed-in
arguments. In the case of a shell script or function, the list "$@",
whose individual members are "$1", "$2", etc, is automatically set to
the arguments passed by the caller.
The "done" is shell for "end repeat".
On 9/6/07, David Wolfe <email@hidden> wrote:
> Thank you Chris,
>
> This is what I thought I should be able to do. But I couldn't figure
> out how to get the Finder selection from the workflow to pass to the
> shell script except to wrap it in an Applescript with a variable. I'm
> assuming where you wrote, "pass input as parameters," you meant to
> say "argument?" The options are Standard Input or Argument. Can you
> explain the script you posted so I can learn how to do things like in
> the future? For example, what does the first line do? What does the
> "$f" mean in the third line? Does "done" make the shell session quit?
>
> Thanks again,
> David Wolfe
>
>
> On Sep 6, 2007, at 4:49 PM, Christopher Nebel wrote:
>
> > On Sep 5, 2007, at 2:22 PM, David Wolfe wrote:
> >
> >> I know this may inflame the Applescript/Shell script debate again,
> >> but I'm trying to automate something that apparently can only be
> >> done at a command prompt. Please prove this wrong and show me an
> >> Applescript way.
> >>
> >> I'm trying to use Automator to create a Finder plug-in that will
> >> allow a right-click on selected file(s) to add those files to the
> >> Dock. So far, I've been able to get the Finder plug-in to work,
> >> calling an Applescript in which I'm using "do shell script" to add
> >> the item(s) to the Dock. But I can't get the selected file to pass
> >> to the Shell Script as an argument. Here is the Workflow:
> >>
> >> Get Specified Finder Items > Run Applescript
> >>
> >> on run {input, parameters}
> >> do shell script "additemtodock "
> >> return
> >> end run
> >
> > If you're using Automator to create a Finder plug-in, then there
> > are two things to be aware of. First, the clicked items will be
> > passed to the workflow -- there's no need, and it's actually
> > incorrect, to get the Finder selection in the workflow itself.
> > Second, if all your Run AppleScript action does is call "do shell
> > script", why not use a Run Shell Script action instead? Your
> > entire workflow would look like this:
> >
> > Run Shell Script (/bin/sh, pass input as parameters)
> >
> > for f in "$@"
> > do
> > additemtodock "$f"
> > done
> >
> >
> > --Chris Nebel
> > AppleScript Engineering
> >
>
>
> _______________________________________________
> 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
>
--
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