"script contains a syntax error" on some machines (Mac client v7.2)

(imported topic written by jstamps91)

A very simple action script is failing on a small percentage of Mac clients with “action script contains a syntax error” for the following line:

if {not exists file “something” whose (size of it = 500 and sha1 of it = “”) of folder “/path/”}

On the majority of clients this frequently recurring action has been successfully applied hundreds of times. In the case of machines w/ these “syntax errors,” the action has been applied only once, though the action parameters specify that it should be reapplied in the event of failure.

It is possible that, owing to the timing of different actions, the directory at “/path/” didn’t exist when this action was first attempted. (Why we’re using different actions for related purposes, and why we’re using a directory path that doesn’t exist by default is a separate, long story. The short explanation is that we did what we had to in order to make the scripts function properly in a majority of cases. Note, however, that I wrote these scripts before we had version 7.2 of the Mac client available for production use.)

At the very least, “syntax error” is a misleading error code. And why isn’t the embedded relevance in this action script being re-evaluated once the directory at “/path/” exists, if that directory’s non-existence was in fact the cause of the original error condition?

Thanks for any advice. -Jay

(imported comment written by Lee Wei)

Hi jstamps,

If the directory might not exists in some cases, we should write the relevance statement to protect against that.

We first check to make sure that the folder exists, then find out about the file within the folder.

if { (exists folder “/path/”) and (not exists file “something” whose (size of it = 500 and sha1 of it = “”) of folder “/path/”) }

Lee Wei

(imported comment written by jstamps91)

Excellent suggestion. I’ll try that first. Thanks. -Jay