• 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: Calling shell script, returning results.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Calling shell script, returning results.


  • Subject: Re: Calling shell script, returning results.
  • From: Steve Hayman <email@hidden>
  • Date: Thu, 18 Dec 2008 10:12:03 -0500

On 18-Dec-08, at 10:04 AM, Michele (Mike) Hjorleifsson wrote:

If you call a shell script from applescript is there a way to capture the resultant output from the shell script so you could present it nicely in the GUI for the user ?


Sure, it's easy. The result of "do shell script" is a string with the command's standard output in it. i.e.


	set currentTime to do shell script "date"
	display dialog "The current time is: " & currentTime

Or if you want to break it into individual lines, use "paragraphs of ...", e.g.

	set filesInSlashBin to paragraphs of (do shell script "ls /bin")
	choose from list filesInSlashBin

(note that some commands write information to standard error, not standard output, and info written to stderr will not be returned; if you want to capture all the output, you can throw in a "2>&1" to merge them both, e.g. do shell script "someCommand 2>&1")


_______________________________________________ Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
References: 
 >Calling shell script, returning results. (From: "Michele (Mike) Hjorleifsson" <email@hidden>)

  • Prev by Date: Calling shell script, returning results.
  • Next by Date: Re: Option Key Down
  • Previous by thread: Calling shell script, returning results.
  • Next by thread: Re: Calling shell script, returning results.
  • Index(es):
    • Date
    • Thread