• 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
do shell script gotcha
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

do shell script gotcha


  • Subject: do shell script gotcha
  • From: Donald Hall <email@hidden>
  • Date: Tue, 25 Feb 2003 00:33:19 -0700

I recently discovered a change in AppleScript behavior in Jaguar that I didn't see in the Release Notes for AS 1.9.

do shell script "ls myFile" returns an empty result if myFile can't be found. In AS 1.8 it returns something like "No such file or directory myFile". I was using the presence or absence of "No" in the result to determine if the file was there or not. Of course this broke in Jaguar, causing my script to give an "unexpected result". To cover both 10.1 and 10.2, I now use:

set shellResult to do shell script "ls myFile"
if shellResult is "" or (offset of "No" in shellResult is not equal to 0) then -- file not found

Perhaps you already knew this, but if not, it might save you the time I spent figuring out what was wrong with my script on 10.2!

Don
--
Donald S. Hall, Ph.D.
Apps & More Software Design, Inc.
email@hidden
http://www.appsandmore.com
_______________________________________________
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.

  • Follow-Ups:
    • Re: do shell script gotcha
      • From: Christopher Nebel <email@hidden>
    • Re: do shell script gotcha
      • From: "Michael P. Wilson" <email@hidden>
  • Prev by Date: Re:(no subject)
  • Next by Date: Re: do shell script gotcha
  • Previous by thread: Re:(no subject)
  • Next by thread: Re: do shell script gotcha
  • Index(es):
    • Date
    • Thread