Re: do shell script gotcha
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.