Monthly Archives: February 2009

Mutt Bash E-mail Script

Send E-mail by Bash Script using Fedora, Cent OS and/or Redhat

This is my guide for “How to send an e-mail using a bash script including an attachment…. In order to send an e-mail with an attachment from a bash script you will need to install the program MUTT, you can use YUM or RPM to install the program.

STEP 1 To install MUTT using YUM or UP2DATE run the following at your command line:

yum install mutt (Fedora and Cent OS method)
up2date mutt (Redhat)

STEP 2 Once installed you can start writing the script. The following is a simple example of how the line should look:

mutt -s “SUBJECT” -a /DIRECTORY_PATH [email protected] < /home/username/mail-message.txt

-s is the subject, where “SUBJECT” should be tittled accordingly
-a is the attachement, where “/DIRECTORY_PATH” should be the path to the file you need to attatch
[email protected]” is the receiver, this is the person who will receive this e-mail
mail-message.txt is the file that is read into the message body in which the recipient will read

STEP 3 To put this all together in a script you would write the following:
(using my favorite text editor emacs I would type: emacs test_email.bsh, don’t forget to change the permissions, set them by typing: chmod +x test_email.bsh, if you don’t make the file executable it won’t run)

#!/bin/bash
mutt -s “this is a test” -a /home/username/log/test.log [email protected] < /home/username/mail-message.txt

The above script would send a message with a Subject of: “this is a test” and would include an attachment of the file: “test.log” and would be sent to” [email protected]

PLEASE NOTE that if you do not have MUTT installed you can send an e-mail using the following command, I am however unaware of a way to send an attachment using this method (this method uses sendmail which is usually installed by default on Linux systems):

echo “message body” | mail -s “subject” [email protected]

[ad#google-468×60]

Turn Off and Delete WordPress Post Revisions

So those post revisions WordPress is storing are starting to build up and you want to clean up… Maybe you want to turn off the post revisions… but you don’t know how, well read the following and you should be set. Please keep in mind I am NOT responsible for anything you might try on your own blog. These instructions are for WordPress 2.7.0, settings maybe changed in newer versions.

I used MySQL GUI tools to do the following however you can do it from the command line. I normally do it from the command line but sometimes GUI can just save time…

— CHECK THE AMMOUNT OF ROWS IN YOUR WP_POSTS TABLE
SELECT * FROM wp_posts WHERE post_type = “revision”;

— CREATE A BACKUP TABLE OF WP_POSTS (SHOULD DATE THE BAK TABLE YYYYMMMDD)
CREATE TABLE wp_posts_bak LIKE wp_posts;

— COPY THE ORIGINAL WP_POSTS INTO THE NEW BACKUP TABLE WP_POSTS_BAK (SHOULD DATE THE BAK TABLE YYYYMMMDD)
INSERT wp_posts_bak SELECT * FROM wp_posts;

— CONFIRM THE AMMOUNT OF ROWS IN WP_POSTS_BAK MATCH THE ROWS IN WP_POSTS
SELECT * FROM wp_posts_bak WHERE post_type = “revision”;

— DELETE THE DATA FROM WP_POSTS WHERE POST_TYPE=”REVISIONS”
DELETE FROM wp_posts WHERE post_type = “revision”;

— COMMIT YOUR DATABASE CHANGES (POINT OF NO RETURN – you can do a “ROLLBACK;” if your unsure)
COMMIT;

In order to stop WordPress from saving post revisions you will need to add the following line of code to the “wp-config.php” file. I recommend backing up the “wp-config.php” file before making any modifications. The method I am showing here assumes that you have shell/terminal or command line access. If you don’t have access to a shell/terminal or command line you can do it through an FTP program.

— BACKUP YOUR WORDPRESS CONFIG FILE BEFORE EDITING
cp -pr wp-config.php wp-config.php.ORIG (or by date wp-config.php_YYYYMMMDD)

— TURN OFF REVISIONS IN WORDPRESS IN wp-config.php by adding the following line
define(‘WP_POST_REVISIONS’, false);

Linux Bash Convert Lower to Upper

Linux Bash Command Line — Convert lower case characters to upper case or the opposite!

So lets say your an anal retentive guy like me and the format of certain things is very important to you as well as key organization of various files which are dated or what I would call a TIMESTAMP. I have many scripts that run and these scripts have log files so in the event of an error I can trace the scripts steps to locate the issue thus requiring a date or TIMESTAMP attached to each file.

Below is sample code that will convert your string from lower case to upper: (this method assumes you have “tr” installed on your host machine – it is “Translate Characters”)

#!/bin/bash
TIMESTAMP=`date +%G%b%d_%H%M`
LOGTIME=`echo $TIMESTAMP | tr “[:lower:]” “[:upper:]”`
echo -e ‘\n———–‘
echo $LOGTIME

The above code will echo a string as follows:

YYYYMMMDD__hhmm

(predefined by the date command, run “date –help” at your command line for more info)
Y = year, digit
M = month, character
D = day of the month, digit
h = hour, digit
m = minute, digit

So my file might look like FULL_SYS_BAK_2009FEB03_2330.log, that way all my files will be consistently named and organized… When you do your “ls -l” to list your directory and everything is organized its much easier on the eye(s).

$ ls -l
FULL_SYS_BAK_2009JAN28_2330.log
FULL_SYS_BAK_2009JAN29_2330.log
FULL_SYS_BAK_2009JAN30_2330.log
FULL_SYS_BAK_2009JAN31_2330.log
FULL_SYS_BAK_2009FEB01_2330.log
FULL_SYS_BAK_2009FEB02_2330.log
FULL_SYS_BAK_2009FEB03_2330.log

The above looks much better than lower case if you ask me, but where it really matters is when you have multiple files with different names! I usually will start my file names with the date rather then the intended file name, it is just easier to narrow/track down the file you need.

I was able to derive this method from the following site(s): Convert to Upper/Lower Function. Please also refer to the following link for the tr command. Last but not least you may also want to look into the date man pages. If any of these links are broken please report them, thank you!

[ad#google-468×60]

Intel Stock Heatsink’s Disappointing – PART 2

Well after trying the Scythe Shuriken I still find my self out of luck! On a positive note the Scythe Shuriken fit my SilverStone LC-13E perfectly but for some reason the fan didn’t work like a fan is supposed to… Before purchasing I read some reviews off of a whole sale website I usually shop at, Memory Express. Two of the three reviews said that the fan stopped working within the first month of use, that deterred me. Well with advice from a good friend and based on the fact that Scythe is a great brand I tried it anyway… Thus leading to the fan problem… Basically while the temperatures were low the fan would throttle down, but it turned itself off and DIDN’T turn itself back on which concerned me as I watched my temps climb above 60 degrees! So I exchanged it for what I should have bought in the first place, a ZALMAN! Now most Zalmans are amazing but the problem with them is that you have to mount a back plate onto the back side of your mother board so that you can actually mount the heatsink. That basically means anytime you have to change it out you have to pull your whole mother board our of the case, not very conveniant.

As always the Zalman brand (my model: CNPS7500-CULED) lives up to the reputation of keeping a processor cool. I have other Zalman products in my other machines and they all do the job, bringing the temperature down an average of 10 degrees.

So all said and done I tried a Intel Stock heatsink, Scythe Ninja Mini, Scythe Shuriken and the Zalman CNPS7500-CULED… my results are still the same, Intel Stock Coolers aren’t good and its better to get an after market cooler. Some of you might say obviously but the fact remains when I buy ANY AMD processor I do NOT have to worry about the temperatures when I run my system with the stock heatsink. You don’t have to buy a crazy heatsink to replace the stock Intel just get a generic one but be sure to do a little research first.

All of my temperature data was collected by both Speedfan and Realtemp. It is worth noting that Intel tells you the “cool, safe, warm and hot” temperatures on their website. Technically their stock fans do the trick but I prefer to run cooler as to extend the longevity of my products.

Intel Stock Heatsink’s Disappointing – PART 1

Well after replacing my fourth Intel Stock Heatsink I think it is safe to say that the Heatsinks which Intel provides don’t actually provide sufficient cooling.

I started with an Intel Pentium D805 which actually ran fairly cool however once I replaced the stock heat sink with an after market Zalman the average temperature dropped almost 10 degrees C! I just recently upgraded the D805 to an E5200 which runs around 35 degrees C (same Zalman heatsink).

My main system runs a Intel Quad Core Extreme 6850. To be fair this chip runs hot period, no matter which heatsink you have this chip just runs hot! I did replace stock heatsink right off the bat as the Intel stock heatsink sounded like a hair blow dryer, man it was loud. I choose yet another Zalman CPU cooler which brought the CPU temperature down 10 plus degrees depending on the task, some temperatures dropped 15 degrees or more!

Now my final problem, to date… Is my new Media Center PC. I bought an Intel Quad Core 9300 which is encased in an Silverstone LC13. With the current stock Intel heatsink I am getting temperature readings up around 60 degrees. Way to hot for my liking so I purchased a Scythe Shuriken and plan to install it tonight, I will post back with results!

If anyone has anything to add please do! I should also mention that I am using Speed Fan to obtain the readings and that I DON’T RECOMMEND USING THE STOCK HEATSINK WHICH SHIPS WITH YOUR INTEL PROCESSOR.