Sunday, October 30, 2011

CGI's in BASH: part 1

It's possible to write quick and dirty cgi scripts in Bash that quickly report information about a system.

uptime

#!/bin/bash
echo Content-type: text/plain
echo
/usr/bin/uptime

Or you can expand this a little

#!/bin/bash
UPTIME=/usr/bin/uptime


echo Content-type: text/plain
echo
if [ -x $UPTIME ];  then
        $UPTIME
else
        echo Cannot find uptime command on this system.
fi

No comments: