Running a script
In order to run a sequence of
JavaScript statements (a script), the shell can be invoked with the name of the script:
$ js24 script.js
The content of script.js
might just be something like this:
var i = 39;
var j = 3;
print(i+j);
Apparently, the -f
option can be used to explicitly state the name of the script:
$ js24 -f script.js
Executable scripts
A script can be
chmod
'ed to contain the executable bit so that a script can be executed directly from the shell:
$ ./executable-script.js
executable-script.js
might look like this:
#!/usr/bin/env js24
print ('This script can be started on');
print ('the shell with:');
print ('');
print (' ./executable-script.js');