Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / phantomjs / lib / phantom / examples / echoToFile.js
1 // echoToFile.js - Write in a given file all the parameters passed on the CLI
2 var fs = require('fs'),
3     system = require('system');
4
5 if (system.args.length < 3) {
6     console.log("Usage: echoToFile.js DESTINATION_FILE <arguments to echo...>");
7     phantom.exit(1);
8 } else {
9     var content = '',
10         f = null,
11         i;
12     for ( i= 2; i < system.args.length; ++i ) {
13         content += system.args[i] + (i === system.args.length-1 ? '' : ' ');
14     }
15     
16     try {
17         fs.write(system.args[1], content, 'w');
18     } catch(e) {
19         console.log(e);
20     }
21
22     phantom.exit();
23 }