<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: arial,helvetica,sans-serif; font-size: 12pt; color: #000000'><font face="arial, helvetica, sans-serif" style="color: rgb(0, 0, 0); font-size: 12pt;">You can clean up your script and save yourself some typing by replacing this style:</font><div style="color: rgb(0, 0, 0); font-size: 12pt; font-family: arial, helvetica, sans-serif;"><br></div><div style="color: rgb(0, 0, 0); font-size: 12pt;"><font face="courier new, courier, monaco, monospace, sans-serif">cmd1 > file</font></div><div style="color: rgb(0, 0, 0); font-size: 12pt;"><font face="courier new, courier, monaco, monospace, sans-serif">cmd2 >> file</font></div><div style="color: rgb(0, 0, 0); font-size: 12pt;"><font face="courier new, courier, monaco, monospace, sans-serif">cmd3 >> file</font></div><div style="color: rgb(0, 0, 0); font-size: 12pt; font-family: arial, helvetica, sans-serif;"><br>with</div><div style="color: rgb(0, 0, 0); font-size: 12pt; font-family: arial, helvetica, sans-serif;"><br></div><div style="color: rgb(0, 0, 0); font-size: 12pt;"><font face="courier new, courier, monaco, monospace, sans-serif">{</font></div><div style="color: rgb(0, 0, 0); font-size: 12pt;"><font face="courier new, courier, monaco, monospace, sans-serif"> cmd1</font></div><div style="color: rgb(0, 0, 0); font-size: 12pt;"><font face="courier new, courier, monaco, monospace, sans-serif"> cmd2</font></div><div style="color: rgb(0, 0, 0); font-size: 12pt;"><font face="courier new, courier, monaco, monospace, sans-serif"> cmd3</font></div><div style="color: rgb(0, 0, 0); font-size: 12pt;"><font face="courier new, courier, monaco, monospace, sans-serif">} > file</font></div><div style="color: rgb(0, 0, 0); font-size: 12pt; font-family: arial, helvetica, sans-serif;"><br></div><div style="color: rgb(0, 0, 0); font-size: 12pt; font-family: arial, helvetica, sans-serif;">Also, I don't know if this is a box you have root on, but you can eliminate storing your password in pw.txt by adding specific commands to your sudoers file with "NOPASSWD:". This can be apropriate for certain commands like yours that are just reporting data. For example, I added this line with visudo:</div><div><font face="courier new, courier, monaco, monospace, sans-serif">splante ALL=(root) NOPASSWD: /usr/sbin/hddtemp</font></div><div><font face="arial, helvetica, sans-serif"><div>And now I can execute this command without a password:</div></font></div><div><div><font face="courier new, courier, monaco, monospace, sans-serif">sudo /usr/sbin/hddtemp /dev/sda</font></div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt;"><br></div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt;">Other commands you may want the safety of having to type the password each time, but if you have the password in a text file you've defeated that purpose anyway. Another alternative would be to run the script that generates the file in root's crontab.</div></div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt;"><br></div><div style="color: rgb(0, 0, 0); font-size: 12pt; font-family: arial, helvetica, sans-serif;">Scott<br><hr id="zwchr"><div style="color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>From: </b>"Ron Frazier (ALE)" <atllinuxenthinfo@techstarship.com><br><b>To: </b>"Atlanta Linux Enthusiasts" <ale@ale.org><br><b>Sent: </b>Thursday, June 6, 2013 11:38:23 PM<br><b>Subject: </b>Re: [ale] [OT] how do I monitor the "weather" in my computer room<br><br>Hi Scott, Alex, and all,<br><br>Thanks for the recent suggestions. I now have a crude and rude, quick <br>and dirty, and somewhat ugly solution running. But ... it is running, <br>which is very cool. Anyone is welcome to use these scripts.<br><br>I first created a script to read the sensors and create a simple crude <br>html data file. I didn't worry with tables. I just use raw text and <br>paragraph markers. The hddtemp command must run as sudo, and pulls its <br>password from a text file. I don't know if that's the best way to <br>handle it or not, but it works.<br><br>-----------------<br><br>checktemps file<br><br>#!/bin/bash<br>cd ~<br><br>echo '<html>' > temperature.html<br><br><br>echo 'Bugs01 Temperatures' >> temperature.html<br>echo '<p>' >> temperature.html<br><br>date >> temperature.html<br>echo '<p>' >> temperature.html<br><br>echo 'CPU - ' >> temperature.html<br>sensors | grep 'temp1' >> temperature.html<br>echo '<p>' >> temperature.html<br><br>echo 'HDD1 - ' >> temperature.html<br>sudo -S hddtemp /dev/sda < pw.txt >> temperature.html<br>echo '<p>' >> temperature.html<br><br>echo 'HDD2 - ' >> temperature.html<br>sudo -S hddtemp /dev/sdb < pw.txt >> temperature.html<br>echo '<p>' >> temperature.html<br><br>echo 'GPU0 - ' >> temperature.html<br>sudo aticonfig --adapter=0 --odgt >> temperature.html<br>echo '<p>' >> temperature.html<br><br>echo 'GPU1 - ' >> temperature.html<br>sudo aticonfig --adapter=1 --odgt >> temperature.html<br>echo '<p>' >> temperature.html<br><br>echo 'GPU2 - ' >> temperature.html<br>sudo aticonfig --adapter=2 --odgt >> temperature.html<br>echo '<p>' >> temperature.html<br><br><br>echo '</html>' >> temperature.html<br><br>----------------<br><br>By the way, even though scripts run without an extension in the file <br>name, is it normal to use an extension?<br><br>I then execute the checktemps script every 15 seconds with:<br><br>watch -n 15 ./checktemps<br><br>Then I use the nc command (starting it by hand) to serve up the data <br>file when requested on a port number other than the default. This must <br>also run as sudo:<br><br>while true; do sudo nc -l 56789 < ./temperature.html; done<br><br>I enter the following address of my basement computer in a web browser <br>on the same subnet:<br><br>http://192.168.81.134:56789/<br><br>I get the following:<br><br>---------------------<br><br>browser result on special port<br><br><html><br>Bugs01 Temperatures<br><p><br>Thu Jun 6 22:57:36 EDT 2013<br><p><br>CPU -<br>temp1: +43.0°C (high = +70.0°C)<br><p><br>HDD1 -<br>/dev/sda: ST9320320AS: 25°C<br><p><br>HDD2 -<br>/dev/sdb: ST95005620AS: 27°C<br><p><br>GPU0 -<br><br>Adapter 0 - AMD Radeon HD 7800 Series<br>Sensor 0: Temperature - 82.00 C<br><p><br>GPU1 -<br><br>Adapter 1 - AMD Radeon HD 6700 Series<br>Sensor 0: Temperature - 79.00 C<br><p><br>GPU2 -<br><br>Adapter 2 - AMD Radeon HD 7800 Series<br>Sensor 0: Temperature - 70.00 C<br><p><br></html><br><br>-----------------<br><br>So, it works. What's weird is that it's actually showing the source <br>text of the html file. However, if I do the same thing on port 80, it <br>actually formats as a web page and looks like this:<br><br>browser result on port 80<br><br>Bugs01 Temperatures<br><br>Thu Jun 6 23:18:55 EDT 2013<br><br>CPU - temp1: +43.0°C (high = +70.0°C)<br><br>HDD1 - /dev/sda: ST9320320AS: 25°C<br><br>HDD2 - /dev/sdb: ST95005620AS: 28°C<br><br>GPU0 - Adapter 0 - AMD Radeon HD 7800 Series Sensor 0: Temperature - 81.00 C<br><br>GPU1 - Adapter 1 - AMD Radeon HD 6700 Series Sensor 0: Temperature - 81.00 C<br><br>GPU2 - Adapter 2 - AMD Radeon HD 7800 Series Sensor 0: Temperature - 71.00 C<br><br>--------------------<br><br>So, I'm getting there. There are still a few problems though:<br><br>A) If I let nc run on port 80, I get a properly displayed web page in <br>the browser. If I don't, I get a display as if I'm looking at the page <br>source.<br><br>B) The sudo authorization for the nc command expires and then my web <br>page no longer loads.<br><br>C) I don't have an autostart sequence running yet.<br><br>D) Sometimes, if I happen to retrieve the file while it's being written, <br>I get an incomplete result.<br><br>E) I cannot CTRL-C to terminate the window with the nc running in it. I <br>have to force close that window.<br><br>Anyway, like I said, getting there.<br><br>Any further suggestions are appreciated.<br><br>Sincerely,<br><br>Ron<br><br><br>-- <br><br>(PS - If you email me and don't get a quick response, you might want to<br>call on the phone. I get about 300 emails per day from alternate energy<br>mailing lists and such. I don't always see new email messages very quickly.)<br><br>Ron Frazier<br>770-205-9422 (O) Leave a message.<br>linuxdude AT techstarship.com<br>Litecoin: LZzAJu9rZEWzALxDhAHnWLRvybVAVgwTh3<br>Bitcoin: 15s3aLVsxm8EuQvT8gUDw3RWqvuY9hPGUU<br><br>_______________________________________________<br>Ale mailing list<br>Ale@ale.org<br>http://mail.ale.org/mailman/listinfo/ale<br>See JOBS, ANNOUNCE and SCHOOLS lists at<br>http://mail.ale.org/mailman/listinfo<br></div><br></div></div></body></html>