问题
I am using SpiderMonkey 1.8.5 on Debian. I am starting a script through the command-line using
js -f <myScript>
I'd like to pass some arguments to my script, but I don't know how to do that. It's supposedto be possible since the documentation tells you about a special object gathring all parameters provided to a script.
I tried the following:
js -f <myScript> <1stArg>
But SpiderMonkey consider both parameters as different scripts to execute and thus sends en error saying the '<1stArg>' file doesn't exist.
What is the correct way to do what I wish?
回答1:
Like this:
In script.js
#!/usr/bin/js
print(arguments);
Then from system shell:
$ chmod +x script.js
$ ./script.js
来源:https://stackoverflow.com/questions/11073713/how-to-pass-arguments-to-a-script-through-the-spidermonkey-command-line