Skip to main content


Install

curl https://runjs.cc/install.sh | sh

–OR–

wget https://runjs.cc/install.sh && sh install.sh

RunJS Command Line

$ runjs
runjs - Run JSSP-JS script.

ERROR: NO arguments assigned!
CMD: runjs file.js | -s script | -i | -I
OR : runjs-debug file.js | -s script | -i | -I
  file.js        assign script file name
  -s script      assign script content
  -i             interactive
  -I             standard input

Interactive Mode

$ runjs -i
script> println('Hello World.');
Hello World.
+ Result: null
script> exit()
+ Bye!

Execute From Standard Input

$ echo 'println("Hello World.")' | runjs -I
Hello World.
$ curl https://runjs.cc/helloworld.js 2>/dev/null | runjs -I
Hello: hatterjiang

Sample - Hello World

$ cat f.js
var main = () => {
    println("Hello World!");
};

main();


$ runjs f.js
Hello World!

Sample - Listing Files

$ cat f.js 
var main = () => {
    $ARRAY($$.file($$.env('HOME')).list())
          .filter((f) => { return f.startsWith('hatter') })
          .filter((f) => { return f.endsWith('.asc') })
          .forEach((f) => { println(f) });
};

main();


$ runjs f.js 
hatter_pgp_2048_c.asc
hatterpubkey4096.asc

Sample - aes.js

$ cat aes.js
#! /usr/bin/env runjs
var AESCrypt = Packages.me.hatter.tools.commons.security.crypt.AESCrypt;

var main = () => {
  AESCrypt.main($ARGS);
};

main();


>> More Samples