Re: do shell script (grep) AppleScript error
Re: do shell script (grep) AppleScript error
- Subject: Re: do shell script (grep) AppleScript error
- From: steve harley <email@hidden>
- Date: Sat, 14 Feb 2004 18:40:04 -0700
on 14 Feb 2004, at 2:29 PM, Graff wrote:
Just to make life a bit easier here's a simple alternative.
If you are using MacOS X and have the Developer Tools installed you
can do most of this in 1 line of shell code:
---------
set sfnt_ to do shell script "/Developer/Tools/DeRez -only sfnt
/path/to/font | grep -c sfnt"
---------
see below -- this will have the same problem.. the man page doesn't
say, but it seems reasonable to assume that DeRez has null output if
the resource type doesn't exist, so this is sufficient:
if "" == do shell script "/Developer/Tools/DeRez -only sfnt
/path/to/font" then
-- there is no sfnt resource
end if
On Feb 14, 2004, at 2:19 PM, Mark Douma wrote:
This works fine in Terminal, but when trying it from within
AppleScript, it results in an AppleScript error with message "0"
(zero), error number "-1".
that's because grep returns an exit status of 1 when no matches are
found.. do shell script interprets this as an error.. the solution is
to add "; exit 0" to the end of your shell command (or avoid the prolem
with DeRez)
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.