• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Applescript-Shell Error Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Applescript-Shell Error Question


  • Subject: Re: Applescript-Shell Error Question
  • From: Axel Luttgens <email@hidden>
  • Date: Sat, 15 Sep 2012 18:35:30 +0200

Le 15 sept. 2012 à 17:16, Christopher Stone a écrit :

> Hey Folks,
>
> This script throws an error if there are items that have no quarantine bit set:
>
> tell application "Finder"
> 	set d to target of front window as string
> end tell
> set d to POSIX path of d
> set cmd to "cd " & quoted form of d & ";xattr -d com.apple.quarantine *"
> do shell script cmd
>
> Is there a way to stop the error from propagating from the shell to Applescript?
>
> I thought I could just do something like: 2>/dev/null
>
> But it doesn't stop Applescript from throwing an error.
>
> I know of course I can just put a try-block in the script, but I'm looking for a little deeper understanding.

Hello Chris,

Trying to delete a non-existing attribute may be viewed as an error condition, in the sense that one should have checked for the attribute's existence beforehand.
That's probably the intent of the one who wrote xattr, since that command exits with a non-null return code under such circumstances.

In your case, it seems that you just want to get rid of possible quarantine attributes set for a bunch of items. The easiest way would then be to make AppleScript happy with a null return code from the shell script:

	set cmd to "cd " & quoted form of d & ";xattr -d com.apple.quarantine * ; exit 0"

Moreover, a 2>/dev/null wouldn't then be needed, since AppleScript ignores data written on stderr in the case of a "successful" execution.

HTH,
Axel


 _______________________________________________
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


  • Follow-Ups:
    • Re: Applescript-Shell Error Question
      • From: Christopher Stone <email@hidden>
References: 
 >Applescript-Shell Error Question (From: Christopher Stone <email@hidden>)

  • Prev by Date: Applescript-Shell Error Question
  • Next by Date: Re: Applescript-Shell Error Question
  • Previous by thread: Applescript-Shell Error Question
  • Next by thread: Re: Applescript-Shell Error Question
  • Index(es):
    • Date
    • Thread