Javascript from shell script

Is it possible to call javascript inside a shell script? For instance,

echo "Content-type: text/html"
echo "
     <html>
     <script type="text/javascript">
     document.write("<p>" + Date() + "</p>");
     </script>
     </html>
     "
+3
source share
4 answers

If your script uses CGI (Common Gateway Interface) , then yes, you can enable HTML with built-in JavaScript.

EDIT: JavaScript is a client technology. You will not get any trace of JavaScript running on the server because it will not execute on the server (unless we are talking about JavaScript on the server side, but I don’t think so).

+2
source

Default: None. But you can install applications that can run javascript like node.js or rhino.

+2
source
+1

You will need to install the javascript engine on your system in order to be able to call it from bash and execute javascript code. Check out SpiderMonkey .

+1
source

All Articles