Feb 102013
 

On this episode we go hardcore Linux. We make our first “script” that isn’t the usual “hello world”. No, we actually build something that could be useful. Is this harder to make then “hello world”? Sure, but not by much. As an added bonus if you keep this script up when your friends are around, you will look like a hardcore Linux user.

First thing is first, you need to install lm-sensors and probe your hardware before this can work. If you haven’t seen that post yet, I recommend looking that over first before trying to write this script.

http://www.greenhornlinux.com/2013/01/12/how-to-install-lm-sensors/

Now, I will include the script in this post. I suppose you could simply just copy the code and be done with it. However, I strongly encourage you follow along and see how this is done. I also recommend that you type out EVERYTHING. This will be the best way to start learning scripts in Linux. When ever I am given a script online that I want to “build” myself, I always type it out and try to dissect it line by line. This is one of the best ways to learn scripting in Linux. If you always copy it, it will be that much harder to learn scripting to make your own cool stuff. If you never have the desire to write your own scripts then by all means copy the code.

Code to be inserted into a text file and changed to an executable is:

#!/bin/sh
x=1
while [ $x -lt 10 ]
do
     clear
     sensors
     sleep 10

done

Sorry, the comment form is closed at this time.