Skip to content

Instantly share code, notes, and snippets.

@dtothefp
Created July 10, 2014 16:23
Show Gist options
  • Select an option

  • Save dtothefp/83560408a5c25363fae3 to your computer and use it in GitHub Desktop.

Select an option

Save dtothefp/83560408a5c25363fae3 to your computer and use it in GitHub Desktop.
Node Spawn
// node executable file phantom_sample.js
var spawn = require('child_process').spawn;
var phantom = require('phantomjs');
var excPath = phantom.path;
var path = require('path');
var args = [
path.resolve( __dirname, 'phantom_exc.js')
];
spawn(excPath, args);
//phantom_exc.js
var system = require('system');
var webpage = require('webpage');
console.log(system, webpage);
@stefanjudis
Copy link

Give that a try for your node script. :)

// node executable file phantom_sample.js

var spawn = require('child_process').spawn;
var phantom = require('phantomjs');
var excPath = phantom.path;
var path = require('path');

var args = [
  path.resolve( __dirname, 'phantom.js')
];

var phantomSpawn = spawn(excPath, args);

phantomSpawn.stdout.on('data', function (data) {
  console.log('stdout: ' + data);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment