ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
First of all, being a previous Microsoft Slave, being pretty good at VB, I got fed up and pretty much completely switched all my PC's to Kubuntu and my Server from Win2k to Ubuntu Server, I am slowly learning. but well luckily there is a great community to guide me. :-)
I'm running Ubuntu Server with lm-sensors installed.
For Cacti I would like to extract the raw temperature and Fan values without the fancy formatting from the sensors command.
So after a lot of searching and testing in /dev, /proc and /sys, I finally found that they are stored in /sys/bus/i2c/devices/9191-0290/
Location: Montpellier, France, Europe, World, Solar System
Distribution: Debian Sarge, Fedora core 5 (i386 and x86_64)
This line in your script:
basically says: put the string 'cat' in variable a and then try to run the command /sys/bus/i2c/devices/9191-0290/temp1_input. To say you want to put the result of the full command "cat /sys/bus/i2c/devices/9191-0290/temp1_input" into the variable, you need to surround it by backticks like that:
The perl example did work (presumably) but perl doesn't print a newline by default, so your prompt overwrote the output:
perl -ne 'print $_ / 1000.0, "\n"' ...
The shell can also do arithmetic itself with $(( ... )). Unfortunately bash is no use in this case as it can only handle integer arithmetic but more powerful shells like zsh can do floating point too, e.g.