Sha256: 02bc8140c8491cd1c84bedeaef1240f09fe68a0d460dc63506f1e57549f2ecef

Contents?: true

Size: 623 Bytes

Versions: 2

Compression:

Stored size: 623 Bytes

Contents

// echoToFile.js - Write in a given file all the parameters passed on the CLI
var fs = require('fs'),
    system = require('system');

if (system.args.length < 3) {
    console.log("Usage: echoToFile.js DESTINATION_FILE <arguments to echo...>");
    phantom.exit();
} else {
    var content = '',
        f = null;
    for ( i= 2; i < system.args.length; ++i ) {
        content += system.args[i] + (i === system.args.length-1 ? '' : ' ');
    }
    
    try {
        f = fs.open(system.args[1], "w");
        f.writeLine(content);
        f.close();
    } catch (e) {
        console.log(e);
    }

    phantom.exit();
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
phantomjs.rb-0.0.2 vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/echoToFile.js
phantomjs.rb-0.0.1 vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/echoToFile.js