sasikala's blog

How to send mail in perl?

Install cpan module MIME::Lite

use MIME::Lite;

if (my $mimemsg = MIME::Lite->new(from=>'', to=>'', subject =>'test mail',type=> 'text/plain', data=>'test msg', encoding=>'8bit'))
$mimemsg->send("sendmail", '/usr/lib/sendmail -t -oi -oem');

If you want to attach file then

if (my $mimemsg = MIME::Lite->new(from=>'', to=>'', subject =>'test mail',type=> 'text/plain', data=>'test msg', encoding=>'8bit'))
path=>'/tmp/test.pdf', filename=>'test.pdf');

$mimemsg->send("sendmail", '/usr/lib/sendmail -t -oi -oem');
more details refer

How to check the system stats in unix box?

using vmstat command , we can get the system stats.

vmstat -S 2 2

The result output looks like below

kthr memory page disk faults cpu
r b w swap free si so pi po fr de sr m0 m1 m2 m3 in sy cs us sy id
0 0 0 16780176 12070768 0 0 189 6 6 0 0 1 10 1 2 1278 2206 936 0 0 99
0 0 0 16699376 12171016 0 0 0 0 0 0 0 0 0 0 1 1010 951 606 0 0 100

from this you can get
1. No of Processes in Run Queue: using r value
2. No of Processes Blocked for I/O, paging, etc: using b value
3. No of Processes runnable but swapped: using w value
4. No of Swap-ins: using si value
5. No of Swap-outs: using so value
6. percentage of User CPU: using us
7. Percentage of System CPU: using sy
8. Percentage of Idle CPU : using id

Drupal : Error : Notice: Undefined index: fbconnect_feed in fbconnect_stream_publish_node_insert() (line 43 of /home/fromne45/pu

When using drupal fbconnect module if your are getting the above error then try this solution:

In file fbconnect/fbconnect_stream_publish/fbconnect_stream_publish.module search function fbconnect_stream_publish_node_insert and Change the line from

if ($_SESSION['fbconnect_feed']['submit'] === TRUE) {


if (isset($_SESSION['fbconnect_feed']) && isset($_SESSION['fbconnect_feed']['submit']) && $_SESSION['fbconnect_feed']['submit'] === TRUE) {

Unix: tee command and its usage

Using tee command, you can write the output to STDOUT and file/files at the same time.

For example

When we list the process using ps -ef
ps -ef > process.txt

The output of the ps -ef written to process.txt.

If we use ps -ef | tee process.txt

The output displayed in STDOUT and written to process.txt also. We can even pass this ps -ef output to another command using another pipe like below

ps -ef | tee process.txt | grep httpd

so entire output of ps-ef stored in process.txt and the process which have httpd text will be displayed in STDOUT.

tee command overwrites process.txt every run. you can use tee -a to append the content to process.txt .

You can store the output to multiple files also using tee command like
ps -ef | tee process.txt process1.txt..

Short cut keys for word document

ctrl + c - To copy text
ctrl + v - To paste the copied content
ctrl + b - To make the text bold
ctrl + f - To search. To continue search use ctrl+alt+y
ctrl + h - To replace text with given text.
ctrl + i - To make the text italic
ctrl + u - To underline the text
ctrl + j - To justify the paragraph
ctrl + l - To left justify the paragraph
ctrl + r - To right justify the paragraph
ctrl + e - To make the text centre
ctrl + d - To change the font and size
ctrl + k - To make a link
ctrl + x - To remove the selected text
ctrl + y - To repeat the last step
ctrl + z - To undo the action
ctrl + t - To create the tabbing in the next line
ctrl + s - To save the file
ctrl + n - To open new document
ctrl + o - To open the document
ctrl + w - To close the documen
ctrl + a - To select all content of the document

How to search pattern exist in the input files in linux / unix

For example file "text.txt" contains

Two friends were planned to go to city.
But it is night time, they have to cross the forest to reach the city.

grep friends

To search text without case sensitive

use -i option
grep -i FRIENDS It searches word friends in text.txt file and displays those lines.

To search pattern in directory and its sub directory recursively
use -r option to search recursively.
grep -ri friends .
It searches word friends in current and its sub-directories and display.

To search pattern and display the file names instead of lines inside each file

use -l option
grep -rli friends *

search all files and sub-directories in the current directory and list file names in which pattern exists.

To search lines which doesn't contain particular pattern

use -v for invert matching.
grep -v friends < text.txt
It display all lines expect those have word friends. so it display only second line.

Syndicate content