• 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: Donald Hall <email@hidden>
  • Date: Tue, 25 Feb 2003 22:44:20 -0700

Chris,

Thanks very much for the suggestion. This is what I ended up with:

try
do shell script "test -e " & POSIX path of myFile
on error
-- myFile doesn't exist, must create it
end try

I was unable to get Chris Nebel's suggestion to work. An error was
always returned whether the file existed or not.

Don

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

--
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: Nigel Smith <email@hidden>
  • Prev by Date: Re: settle! was Re: Scripting Mail:get selection
  • Next by Date: Re: Dictionaries was Re: Scripting Mail:get selection
  • Previous by thread: Re: do shell script gotcha
  • Next by thread: Re: do shell script gotcha
  • Index(es):
    • Date
    • Thread