Script Failure

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Script Failure Thu Dec 17, 2009 11:13 pm • by Spydi
I just updated to 2.3.5 (v623) and I'm getting a script error now on one of my rules. The script reads as follows:
Code: Select all
xattr -d com.apple.quarantine "$1"

It wasn't giving me issues before, but I was wondering if anyone has any suggestions.

Thanks.
Spydi
 
Posts: 8
Joined: Sun Sep 20, 2009 8:51 pm

Re: Script Failure Fri Dec 18, 2009 12:56 pm • by Mr_Noodle
What kind of error are you getting in the log? Is it happening on a particular file or across the board?
Mr_Noodle
Site Admin
 
Posts: 11881
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Script Failure Mon Dec 21, 2009 8:58 pm • by Spydi
Code: Select all
2009-12-21 17:55:51.584 hazelfolderwatch[719] selected_files_20091217-201549.nzb: Rule nzb matched.
xattr: /Users/echernuka/Downloads/selected_files_20091217-201549.nzb: No such xattr: com.apple.quarantine
2009-12-21 17:55:51.651 hazelfolderwatch[719] [Error] Shell script failed: Error processing shell script on file /Users/echernuka/Downloads/selected_files_20091217-201549.nzb


Its happening only on nzb files currently since thats its the only filetype I'm referencing in my rule.
Spydi
 
Posts: 8
Joined: Sun Sep 20, 2009 8:51 pm

Re: Script Failure Mon Dec 21, 2009 9:16 pm • by Mr_Noodle
It looks like the xattr command is bailing because the quaratine extended attribute doesn't exist. This doesn't have anything to do with the ugprade. I suspect it's just a coincidence and that you just didn't run into this case until after the upgrade.

You can jigger the script to return success regardless of whether the xattr command succeeds. This may mask other errors in the future though. To do it, just do a script like:
Code: Select all
xattr -d com.apple.quarantine "$1"
exit 0

The better way to do it is run 'xattr' to see what attributes are there then only delete it if is exists. Something like:
Code: Select all
#!/bin/sh

attr="com.apple.quarantine"
output=`xattr "$1" | grep "$attr"`

if [ -n "$output" ]; then
    xattr -d "$attr" "$1"
fi

Give one of those a try.
Mr_Noodle
Site Admin
 
Posts: 11881
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Script Failure Mon Dec 21, 2009 9:22 pm • by Spydi
Mr. Noodle,

Thanks so much. The 2nd version with the if statement seems to have cleared up the issue completely and now it runs uninterrupted again.
Spydi
 
Posts: 8
Joined: Sun Sep 20, 2009 8:51 pm


Return to Support

cron