child_process does not works for Phantomjs having argument

67 views
Skip to first unread message

Hyo-Han Kim

unread,
Jun 17, 2014, 11:13:05 AM6/17/14
to nod...@googlegroups.com


I am tring to run phantomjs in nodejs script.. 

See follows.. It works fine.. 

var spawn = require('child_process').spawn  ;
var phantom_process= spawn('phantomjs' , 'script.js'  );


But I need cookie file and tried this.

var spawn = require('child_process').spawn  ;
var phantom_process=spawn('phantomjs', ['script.js', ' --cookies-file=./cookie.dat ' ] );

It runs but does not create cookie anywhere .. 

How can I run phantomjs with Argument within nodejs ?. 


Aria Stewart

unread,
Jun 17, 2014, 7:27:12 PM6/17/14
to nod...@googlegroups.com
On Jun 17, 02014, at 11:13, Hyo-Han Kim <hyo.h...@gmail.com> wrote:
> var spawn = require('child_process').spawn ;
> var phantom_process=spawn('phantomjs', ['script.js', ' --cookies-file=./cookie.dat ' ] );

That looks correct — but are you being surprised by what the current directory is in your script?

Aria
signature.asc

Ryan Schmidt

unread,
Jun 18, 2014, 6:01:53 PM6/18/14
to nod...@googlegroups.com

On Jun 17, 2014, at 10:13 AM, Hyo-Han Kim wrote:

> var phantom_process=spawn('phantomjs', ['script.js', ' --cookies-file=./cookie.dat ' ] );

Try removing the leading and trailing spaces of the last argument:
Reply all
Reply to author
Forward
0 new messages