Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/417.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
来自shell脚本的Javascript_Javascript_Bash_Shell_Cgi - Fatal编程技术网

来自shell脚本的Javascript

来自shell脚本的Javascript,javascript,bash,shell,cgi,Javascript,Bash,Shell,Cgi,可以在shell脚本中调用javascript吗? 比如说, echo "Content-type: text/html" echo " <html> <script type="text/javascript"> document.write("<p>" + Date() + "</p>"); </script> </html> " echo“内容类型:文本/h

可以在shell脚本中调用javascript吗? 比如说,

echo "Content-type: text/html"
echo "
     <html>
     <script type="text/javascript">
     document.write("<p>" + Date() + "</p>");
     </script>
     </html>
     "
echo“内容类型:文本/html”
回声“
文件。写(“”+日期()+“

”); "
试试。

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

如果应用程序使用您的脚本,则可以将HTML与嵌入式javascript一起使用


编辑:JavaScript是一种客户端技术。您不会在服务器上得到任何JavaScript运行的痕迹,因为它不会在服务器上执行(除非我们讨论的是服务器端JavaScript,但我不这么认为)。

您需要在系统上安装一个JavaScript引擎,以便能够从bash调用它并执行JavaScript代码。检查。

如果可以,您希望发生什么?这个问题可以用很多不同的方式来回答,这取决于你想做什么。@thetux:我不确定你想实现什么-请看我的评论。在搜索了我们的论坛后,我发现您的问题可能与此问题过于相关:也可以使用命令
node name\u of_script.js
从shell脚本启动node.js脚本。