How To Prevent A PERL Script From Running As Root

At or near the top of your app, before it executes anything sensitive, place the following code:

if((getpwuid($<) eq "root") || ($< == 0)){ print STDOUT "Cannot run as root!\n"; exit(1); }

How to do this in Python: how-to-prevent-a-python-script-from-running-as-root

Did you find this post useful or have questions or comments? Please let me know!

Posted in How Tos, perl, Programming | 1 Comment

How to Calculate BTU from Watts

This post came about because I got a lot of hits from people looking for this information on the How To Calculate Server Heat post.

1 Watt will produce 3.412 BTU per hour

To calculate the BTU/heat output of an electrical system, substitute BTUs for Watts and use the following equation:

BTU/h = (V * I) * 3.412

Where:
V = Volts
I = Amperes (Amps or Current)

Using the simple math above, we can calculate the heat produced by an appliance on a 120v (US Standard) system drawing 2 Amps for 60 minutes (1 hour).

BTU/h = 3.412 * (120 * 2) = 818.88BTU

Did you find this post useful or have questions or comments? Please let me know!

Posted in How Tos | 13 Comments

HOWTO Turn off Line Numbers in VI

I always forget how to turn off line numbers in VI. The answer is: set nonumbers or set nonu. It’s all about the little things…

Did you find this post useful or have questions or comments? Please let me know!

Posted in How Tos, linux | Leave a comment