Search the web
Sign In
New User? Sign Up
jsosa · JavaScript OSA-Talk
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want to share photos of your group with the world? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Console Output in Terminal?   Message List  
Reply | Forward Message #515 of 529 |
Re: Console Output in Terminal?

Ah, ok..:

var Test = "Hello World";
MacOS.appSelf().do_shell_script("echo " + Test);

Seemed to do the trick. Would be nice to just have Core.Write() or
Core.Print(), but as you say - easy enough to add in via my own
function..


--- In jsosa@yahoogroups.com, Mark Alldritt <alldritt@...> wrote:
>
> Hi,
>
> > I'm running a script via terminal using:
> > osascript -lJavaScript filename.js
> >
> > but I can't seem to be able to output any text to the terminal.
> > Core.message is designed for popups (and doesnt work anyways),
print,
> > output, write, etc don't seem to work.
> >
> > Does anyone know any way to just output a line of text?
>
> The problem here is the osascript tool. There is a 'log'
AppleEvent for
> this purpose, but osascript does not seem to respond to it.
>
> Testing from AppleScript, it does not seem to work:
>
> osascript -e 'log "testing"'
>
> If this were to work, you could generate the same event from JS.
>
> Now, if you only want to display one block of text, you can return
it as the
> value of the script:
>
> osascript -lJavaScript -e '"Testing"'
>
> The only alternative I can think of is dropping down to the shell:
>
> osascript -e 'do shell script "echo testing"'
>
> Which works. So, in JSOSA this would look like:
>
> osascript -lJavaScript -e 'MacOS.appSelf().do_shell_script("echo
testing")'
>
> You can wrap this in a function and add it to the Core object and
then its
> available everywhere.
>
> Cheers
> -Mark
>
> --------------------------------------------------------------------
----
> Mark Alldritt Late Night Software Ltd.
> Phone: 250-380-1725 Script Debugger 4.0 -
AppleScript IDE
> WEB: http://www.latenightsw.com/ FaceSpan 4.3 - AppleScript RAD
> Affrus 1.0 - Perl Debugging
>





Thu Jan 4, 2007 4:47 pm

smakofsky
Offline Offline
Send Email Send Email

Forward
Message #515 of 529 |
Expand Messages Author Sort by Date

I'm running a script via terminal using: osascript -lJavaScript filename.js but I can't seem to be able to output any text to the terminal. Core.message is...
smakofsky
Offline Send Email
Jan 4, 2007
3:08 pm

Hi, ... The problem here is the osascript tool. There is a 'log' AppleEvent for this purpose, but osascript does not seem to respond to it. Testing from...
Mark Alldritt
malldritt2000
Offline Send Email
Jan 4, 2007
4:39 pm

Ah, ok..: var Test = "Hello World"; MacOS.appSelf().do_shell_script("echo " + Test); Seemed to do the trick. Would be nice to just have Core.Write() or ...
smakofsky
Offline Send Email
Jan 4, 2007
4:52 pm

Hi Steve, Instead of JSOSA, you may want to consider using a Java based JavaScript engine: For example... ...
John Love-Jensen
eljay@...
Send Email
Jan 4, 2007
6:54 pm

I initally tried rhino before I found JSOSA - but it didnt appear to be able to interact with apple events. Do you know if it can? ... JavaScript ... ...
smakofsky
Offline Send Email
Jan 5, 2007
2:43 pm

Hi, ... JavaScript OSA's ability to generate AppleEvents is its unique feature. JavaScript OSA uses the Spider Monkey (Mozilla's C JavaScript implementation)...
Mark Alldritt
malldritt2000
Offline Send Email
Jan 5, 2007
3:59 pm

Which is the *exact* reason I'd rather use JSOSA. Having apple event support is killer. Being new to the mac world, I'm surprised that OSA (specifically ...
smakofsky
Offline Send Email
Jan 5, 2007
5:14 pm

Hi, ... That's probably a subject for an entire book. The OSA (Open Scripting Architecture) predates Windows Scripting Host and was a very good idea, though...
Mark Alldritt
malldritt2000
Offline Send Email
Jan 5, 2007
6:32 pm

... I do not know. I presume it does not, given that it is Java based and runs in a JVM. (Not that running in a JVM makes it impossible to interact with AE....
John (Eljay) Love-Jen...
eljay@...
Send Email
Jan 5, 2007
3:25 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help