简体   繁体   中英

Javascript from shell script

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

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

默认情况下:否。但您可以安装可运行javascript(如node.js或rhino)的应用程序。

If your script is used by CGI (Common Gateway Interface) application, then yes, you can include HTML with embedded JavaScript.

EDIT: JavaScript is a client-side technology. You won't get any trace of JavaScript running on server, because it won't be executed on server (unless we're talking about Server Side JavaScript but I don't think so).

试试RhinoShell

You'll need to install a javascript engine on your system to be able to call it from bash and execute your javascript code. Check SpiderMonkey .

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM