我有一个扩展名为 .sh 的可执行文件。我想用终端通过 firefox 打开这个文件,但它返回一个错误:
"filename.sh" can't be opened because Firefox is not allowed to open documents in Terminal.
现在,我该如何更改权限来解决这个问题?
最佳答案
可以在此处找到在所有现代浏览器中使用 javascript 的更安全的方法:
安装 websocketd 服务器(单个静态链接二进制文件) 从http://websocketd.com/下载
启动 websocketd 服务器:
./websocketd --port=8080 --devconsole ./command.sh
编写一个 HTML 页面和一个小的 bash 脚本
HTML:
<button type = "button"
onclick = ws.send("xterm\040#started")>xterm </button>
Javascript 打开一个网络套接字:
var ws = new WebSocket('ws://localhost:8080/');
Bash 脚本(command.sh):
#!/bin/bash
export DISPLAY=:0.0
while read command
do
eval $command
done
更多详情: http://www.bitkistl.com/2016/01/websockets-with-interactive-bash-script.html
关于firefox - 如何用火狐打开终端?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31087326/