[ale] [OT] how do I monitor the "weather" in my computer room

JD jdp at algoloma.com
Fri Jun 7 14:34:09 EDT 2013


On 06/07/2013 02:04 PM, Scott Plante wrote:
> You can clean up your script and save yourself some typing by replacing this style:
> 
> cmd1 > file
> cmd2 >> file
> cmd3 >> file
> 
> with
> 
> {
>   cmd1
>   cmd2
>   cmd3
> } > file
> 
> 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:
> splante  ALL=(root) NOPASSWD: /usr/sbin/hddtemp
> And now I can execute this command without a password:
> sudo /usr/sbin/hddtemp /dev/sda
> 
> 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.

In other shells, "echo" is an external command - spawns a subprocess (i.e. is
more expensive).  I think it is built-in for bash.  For something like this,
that probably doesn't matter at all, but if you can merge the commands into a
single "echo" that uses multi-line features, you can up the efficiency a little.
 At the Beginning Bash session at ALE-NW a few months ago, it was recommended to
use printf over echo. Could have been simply for more control over the
placement.  Sorry, I don't recall the details anymore.

OTOH, every script will always have someone saying there are better ways to
accomplish X, so as long as it works and always works the way you need it, I
wouldn't touch it.  "Perfect is the enemy of done."

Creating bullet proof scripts is very hard, but creating good-enough scripts is
relatively easy.

Congratulations!

If you haven't already done this, it is extremely common for users to have a
~/bin/ folder and add that to their personal PATH.  I'm extremely careful to
take my ~/bin/ with me to new jobs and across different machines at home so my
personalized scripts are always available.  Most of the time, those scripts are
just examples that I remember later for how to use a specific bash, csh, ksh,
sh, perl, python, ruby construct.  I'm forever looking up the 'foreach', as an
example.




More information about the Ale mailing list