This post concerns installing and using erlang_js, together with some sample code to demonstrate how to run and extract data from SpiderMonkey using erlang_js.
When installing erlang_js, you need a current version of Erlang. R14b04 (PPA)
according to Sean Cribbs (#riak @ Freenode), this is the version I used, previous versions from 2009 do not seem to work. Initially, I used a mercurial repo to fetch the erlang_js code, but I was later informed that I should use the GitHub repo instead, perhaps this is more up to date.
In order to execute javascript, we need (according to erlang_js docs):
For (1), this means we should supply -boot start_sasl to the erl
commandline.(2) means we should add the path to the erlang_js binary to the erl
path with -pa, and then execute erlang_js:start(). This amounts to:
erl -boot start_sasl -pa ebin -eval 'erlang_js:start().'
Now we are ready to run javascript!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To run this code, start erlang with: erl -boot start_sasl -pa ebin, compile the example code with c() and simply run js_test:run().
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Very good job!
ReplyDelete