To quote http://www.mozilla.org/rhino/:
- on the command line, so you can shell scripts
Let's see how you can install Rhino on OSX.
Step 1 - download and unzip
Download the binary from the Rhino site and unzip to a temporary directory, say
/tmp. On the command-line:
$ curl ftp://ftp.mozilla.org/pub/mozilla.org/js/rhino1_7R1.zip > /tmp/rhino.zip $ cd /tmp $ unzip rhino.zip
Now you have the file
Step 2: move js.jar where Java can find it
Your default Java install (comes "free" with OSX) will look for class libraries in a predefined directory
~/Library/Java/Extensions. This directory may not exists, so create it and move the js.jar there.
$ mkdir ~/Library/Java $ mkdir ~/Library/Java/Extensions $ mv /tmp/rhino1_7R1/js.jar ~/Library/Java/Extensions/
Step 3: Done! Now test it
That's all there is, your Rhino install is ready to use. To launch and test the Rhino shell try:
Last example - create a script that reads the HTML source of my blog:
$ echo "print(readUrl('http://phpied.com'))" > read.js
now you have a script called read.js, let's run it:
Thanks for reading!
And happy JS-scripting!