-2

Can any one please help me fix this so I can get it to work without the variables set and with my proxy and email hardcoded. The script bellow throws me an error

The node command to start my node script is :

node new.js "proxy" "email"

Code of new.js script :

sys = require('sys')

var exec = require('child_process').exec;

var value = process.argv[2];

var value1 = process.argv[3];

function puts(error, stdout, stderr) {sys.puts(stdout)}

exec("casperjs test.js" value value1, puts);

Here is the error I receive:

/root/new.js:11
exec("casperjs test.js" value value1, puts);
                    ^^^^^
SyntaxError: Unexpected identifier
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:902:3
Brice Favre
  • 1,511
  • 1
  • 15
  • 34
user3290741
  • 37
  • 1
  • 1
  • 6
  • http://stackoverflow.com/questions/4351521/how-to-pass-command-line-arguments-to-node-js - I think it has the answer – Olimpiu POP Feb 13 '14 at 21:09

1 Answers1

1

you need to concatenate your exec string.

exec("casperjs test.js " + value + " " + value1 , puts);
corn3lius
  • 4,857
  • 2
  • 31
  • 36
  • Exactly the answer I was looking for I knew that was the culprit I just could not figure it out thanks I will accept this answer as soon as I can – user3290741 Feb 13 '14 at 21:14