开发者

Javascript from shell script

Is it possible to call jav开发者_如何学Goascript inside a shell script? For example,

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


By default: No. But you could install applications that can run javascript like node.js or 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).


Try 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜