• 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: Getting values returned by Unix command-line programs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting values returned by Unix command-line programs


  • Subject: Re: Getting values returned by Unix command-line programs
  • From: Christopher Nebel <email@hidden>
  • Date: Thu, 18 Mar 2004 01:52:24 -0800

On Mar 17, 2004, at 11:52 PM, steve harley wrote:

a nonzero return status from the shell command throws an error, so you could use a try block ... i had just mentioned in another thread that it's unfortunate that do shell script works this way. i think non-zero return status from shell commands is not semantically equivalent to AppleScript's notion of an error.

In fact, for almost all commands, non-zero status means something went wrong -- no such file, bogus arguments, etc. test(1) is the exception, not the rule. Equivalents to "do shell script" in other languages all return stdout as their result, same as "do shell script" does -- what are you suggesting?

because of that i'd lean toward something like this instead:

set retval to do shell script "if myprog ; then echo 0 ; else echo 1 ; fi

Other equivalents include

do shell script "myprog && echo 0 || echo 1"

and my personal favorite,

do shell script "myprog; echo $?"


--Chris Nebel
AppleScript Engineering
_______________________________________________
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: Getting values returned by Unix command-line programs
      • From: steve harley <email@hidden>
References: 
 >Getting values returned by Unix command-line programs (From: Rob Lewis <email@hidden>)
 >Re: Getting values returned by Unix command-line programs (From: steve harley <email@hidden>)

  • Prev by Date: Re: do shell script and prompts
  • Next by Date: Re: do shell script "perl... " to find/replace in a string
  • Previous by thread: Re: Getting values returned by Unix command-line programs
  • Next by thread: Re: Getting values returned by Unix command-line programs
  • Index(es):
    • Date
    • Thread