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

Re: do shell script gotcha


  • Subject: Re: do shell script gotcha
  • From: Chris Janton <email@hidden>
  • Date: Tue, 25 Feb 2003 06:34:28 -0700

On Tuesday, February 25, 2003, at 01:48 AM, Donald Hall wrote:

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

odd - on my Jaguar system I still get the string...here's a different way to test for a file in the shell

set noFile to false
try
do shell script "test -e ~/.profile"
on error
set noFile to true
end try

There are all sorts of fun things that "test" can do. the "-e" succeeds if a file of any type exists with the name specified. In this case test will return 0. If the file doesn't exist test returns 1 which causes do shell script to throw an error...

hope this helps.

8)
----------------------------------
Chris Janton - face at CentosPrime dot COM
Netminder for Opus1.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.

  • Prev by Date: Re: percentages (was re: repeat with i in string optimization)
  • Next by Date: Re: Re: Some date math
  • Previous by thread: Re: do shell script gotcha
  • Next by thread: Re: do shell script gotcha
  • Index(es):
    • Date
    • Thread