I am new to learning bash script programming and was wondering if anyone here knows how can I execute javascript that would normally be embedded into an html page?
So from a bash script, I would like to execute ( for example ):
<script type="text/javascript" src="scriptName.js"></script>
Thank you very much for anyone's help.
You'll need a Javascript runtime like Node.js .
To evaluate a snippet of code: $ node -e "console.log('hello')"
To run a script: $ node script.js
How about using env like:
my-file
#!/usr/bin/env node
console.log("hello from test file");
Make the file executable.
chmod +x my-file
Then run it:
node my-file
hello from test file
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.