Re: Calling shell script, returning results.
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