最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

bash - Javascript from shell script - Stack Overflow

programmeradmin1浏览0评论

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>
     "

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>
     "
Share Improve this question edited May 11, 2011 at 14:48 thetux4 asked May 11, 2011 at 14:16 thetux4thetux4 1,63310 gold badges28 silver badges38 bronze badges 1
  • What would you expect to happen if you could? This could be answered in so many different ways depending on what you're trying to do. – John Kugelman Commented May 11, 2011 at 14:18
Add a ment  | 

4 Answers 4

Reset to default 3

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)

  1. 暂无评论