简体   繁体   中英

How to make WEB cgi script for system information (Based on BASH scripting lang)

那么我如何获得:

Before any output, your bash CGI script should print a "Content-type" header, for example:

# First output line should be the content-type header + blank line
echo -e "Content/type: text/plain\n"

echo -n "running as: "; whoami

echo "-----------------------------------------"
echo "            /proc/cpuinfo                "
echo "-----------------------------------------"
cat /proc/cpuinfo

echo "-----------------------------------------"
echo "            /proc/meminfo                "
echo "-----------------------------------------"
cat /proc/meminfo

In most apache deployments there is a cgi-bin directory where you should place CGI scripts. Make your script executable (by the user running the webserver) and place it at this directory.

If the user running the webserver has no rights to display the system information you need, you will have to use something like sudo to escalate privileges - be sure to use a very restrictive sudoers file (if you can't sudo, get out of here).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM