• 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: osascript and text output
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: osascript and text output


  • Subject: Re: osascript and text output
  • From: xcgr <email@hidden>
  • Date: Sun, 27 Jul 2008 23:37:37 -0700 (PDT)

That only works if your echo handler is called at the very end of the
run handler. It does not produce any output if you call it earlier in
the script.

Here's an example. It's similar to your script, except that I am calling
your echo handler twice instead of once:

osascript -e '
   on run
       echo("Hello World!")
       echo("Goodbye World!")
   end run

   to echo(something)
      do shell script "echo " & quoted form of something
   end echo
'

You would think the output would be:
   Hello World!
   Goodbye World!

But the actual output is:
   Goodbye World!

The run handler is returning "Goodbye World" as its result because that
was the final command in the script. If you added 'return "foobar"' at
the end of the run handler, the output would be "foobar" instead.

I can't find any way to get text output from a command-line AppleScript,
except as the final result returned by the run handler. It would be nice
if I could write output while the script is still running.

-JB


--- On Mon, 7/28/08, Skeeve <email@hidden> wrote:

> From: Skeeve <email@hidden>
> Subject: Re: osascript and text output
> To: "asu" <email@hidden>
> Date: Monday, July 28, 2008, 12:43 AM
> xcgr schrieb:
> > similar to using the "echo" command in a
> shell script.
> >
> Why don't you use "echo"?
>
> osascript -e '
>     on run
>         set helloworld to "Hello World!"
>         echo(helloworld)
>     end run
>
>     to echo(something)
>        do shell script "echo " & quoted form
> of something
>     end echo
> '
>
> Okay: More complicated then necesary ;-) But now you have
> an echo-handler





 _______________________________________________
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

  • Follow-Ups:
    • Re: osascript and text output
      • From: Skeeve <email@hidden>
References: 
 >Re: osascript and text output (From: Skeeve <email@hidden>)

  • Prev by Date: Is "frontmost application" depreciated
  • Next by Date: Re: osascript and text output
  • Previous by thread: Re: osascript and text output
  • Next by thread: Re: osascript and text output
  • Index(es):
    • Date
    • Thread