System is a module to retrieve some system informations.
var system = require('system')
An array containing a list of arguments on the command line given to the script. The first one (at index 0) is always the script name.
var numberOfArg = system.args.length;
var thirdArgument = system.args[2];
An object having information about the operating system. Here are its properties:
Always returns 0 (no Mozilla API to retrieve the PID)
Returns "slimerjs".
Same as stderr.
Same as stdin.
Same as stdout.
The standard output stream. This is an object with the same API as a file (/dev/stdout on MacOs and Linux) opened with the mode “w” with encoding set by phantom.outputEncoding (UTF-8 by default) or --output-encoding.
You can output binary content (for chained commands for example).
// myscript.js
phantom.outputEncoding = 'binary';
var page = require('webpage').create();
page.viewportSize = { width:600, height:800 };
page.open(url, function(success) {
if (success == "success") {
let bytes = page.renderBytes({format:'png'})
if (bytes) {
system.stdout.write(bytes);
phantom.exit(0);
}
}
phantom.exit(1);
})
And on the command line:
slimerjs myscripts.js > image.png
slimerjs myscripts.js | convert - test.jpg
Note: binary output is not really supported on Windows.
The standard error stream. Same behavior of stdout but on /dev/stderr.
On windows, it is the output stream.
The standard input stream. This is an object with the same API as a file opened with the mode “rb” with no encoding.
It is not available on Windows.
var input = system.stdin.read()