uptime.cgi not working 100%
I'm trying to display uptime.cgi on my webserver. I'm using apache on fc6 64-bit. When the uptime.cgi gets called it displays everything correctly on the webpage except for # of users logged in. It always shows 0 as a value if if I have multiple users connected to my box via ssh or locally (tty and/or gui).
I did some debugging by running the bash script locally and it works fine. It shows the number of users logged in. I also checked who is running the script with whoami. When I run it locally in my shell its my current user and when its run on the web server its apache. So I also tried changing the user in httpd.conf to my user instead of apache and still got the same problem.
Here's a copy of my uptime.cgi in my /var/www/cgi-bin,
have any of you had this problem? I couldn't find anything at all related to this on google for the past week. Thanks.
#!/bin/bash
echo "Content-type: text/html"
echo ""
echo "<html><head><title>Bash as CGI"
echo "</title></head><body>"
echo "<HTML><HEAD><TITLE>SERVER UPTIME (C) 2000"
echo "</TITLE></HEAD><BODY><H1><CENTER>"
echo "Server Uptime for: <FONT COLOR=blue> linuxcore </FONT></H1>"
echo "<HR><BR><B><CENTER>"
echo `uptime`
echo "</B><BR><BR><HR><BR>"
echo "<A HREF="/index.html"> [ HOME ] </A><BR><BR>"
echo "Copyright (C) 2000, All Rights Reserved."
echo "</CENTER></BODY></HTML>"
note: I also tried $(uptime) instead of `uptime` and several other variations withtout success. And finally, someone in #fedora on freenode.net told me that in fc6 gui users are not counted. So why would it work in the shell locally? And if I press control-shift-1 and log in a tty user is still doesnt count it via the webpage.
Sample output from the webpage:
10:11:07 up 9:34, 0 users, load average: 0.58, 0.55, 0.36
Sample output from the shell:
10:11:53 up 9:35, 2 users, load average: 0.43, 0.50, 0.35
Notice the # of users. Now this is the same script being run.
Thanks
Last edited by cizzi; 03-30-2007 at 09:25 AM.
|