编写shell命令,在js里执行就可以了。
#!/bin/sh
echo -e "Content-type: text/plain;charset=utf-8\n"
result=`shutdown -h now`
echo "$result"
测试中遇到的问题就是权限问题,试了使用setuid更改脚本文件权限,使用sudo命令执行,发现在Arch Linux上都挺麻烦的,先临时把mini_httpd的用户权限改高点,下次再试试别的方法。
Failed to set wall message, ignoring: The name org.freedesktop.PolicyKit1 was not provided by any .service files
Failed to reboot system via logind: The name org.freedesktop.PolicyKit1 was not provided by any .service files
Failed to talk to init daemon.
system management
2019-03-21 遇到的一点小问题
今天在测试cgi文件时遇到500 Internal Error错误Something unexpected went wrong running a CGI program.。
500 Internal Error
找了一阵子原因才发现是我的.cgi文件没有执行权限,
使用ls -ail命令打印如下:
14286865 -rw-r--r-- 1 root root 93 Mar 21 09:57 wannoo.cgi
使用命令增加文件执行权限
chmod u+x wannoo.cgi
使用ls -al命令打印如下:
-rwxr--r-- 1 root root 93 Mar 21 09:57 wannoo.cgi
再次测试后可以了。
修改权限:chmod u+x wannoo.cgi
u 代表用户. g 代表用户组. o 代表其他. a 代表所有.
+增加权限. -减少权限