Reputation: 12034
casperjs script.js "myurl" "myemail" "my name"
Here is the script:
url = (casper.cli.get(0));
email = (casper.cli.get(1));
name = (casper.cli.get(2));
this.echo(name);
console.log(name);
The result is: my
(and not my name
).
I also tried with single quotes.
Upvotes: 1
Views: 585
Reputation: 532
You can just escape the spaces with a backslash and DON'T use quotes, for example:
casperjs test.js myurl myemail my\ name
I don't know for sure if it is dependend to the console you are using, under ubuntu (docker) that worked for me:
var casper = require('casper').create();
var targetUrl = 'http://www.test.com/';
casper.start(targetUrl, function() {
url = (casper.cli.get(0));
email = (casper.cli.get(1));
name = (casper.cli.get(2));
this.echo(url);
this.echo(email);
this.echo(name);
console.log(name);
});
casper.run();
Result was:
myurl
myemail
my name
my name
For a windows command line that worked:
casperjs test.js myurl myemail \"my name\"
Upvotes: 4