On Jan 20, 2011, at 15:01, Ronald J Kimball wrote:
> Once you get to AppleScript, you've moved beyond my areas of knowledge.  :)
> 
> You could try redirecting stderr to /dev/null:
> 
> find ... 2>/dev/null
> 
> But be aware that that will throw away all errors, not just the permission 
> denied ones.
______________________________________________________________________

Hey Ronald,

That works nicely from the shell but still throws an error in Applescript.

There may be a way to capture stderr in Applescript, so I can trap for other 
errors.  I'll look into it.

I like 'find' and use it for a number of things, so I very much appreciate the 
edification.

In this particular application I'm going to use 'mdfind'.  It's a little faster 
and doesn't throw an error for those permissions.

Hmm.  In Applescript:

This returns the primary listing, and I *know* there's been an error:

try
  set shellCmdStr to "find /Applications/ -name \"*.app\" -prune 2>/dev/null"
  set findOutput to do shell script shellCmdStr
on error errMsg number errNum
  if errNum = 1 then
    set findOutput to errMsg
  end if
end try

However I don't get the specific error text unless I remove "2>/dev/null".

This on the other hand produces the same output as the Terminal:

try
  set shellCmdStr to "find /Applications/ -name \"*.app\" -prune 2>&1"
  set findOutput to do shell script shellCmdStr
on error errMsg number errNum
  set findOutput to errMsg
end try

Applescript apparently automatically bifurcates the command/error streams, but 
so far I don't find a way to automagically capture them both to different 
variables.  (I can get the error number but not the error text, although I can 
get get around this if I run the script twice in the event of an error - with 
different options).

I'll ask on the Applescript Users List.

Thanks again.

--
Best Regards,
Chris

-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem, 
please email "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

Reply via email to