Thursday, May 28, 2015

Sending mail with HTML content in PERL

Continue with my previous post, here you can find sending an email with HTML content in mail body.

#!/usr/bin/perl
use FileHandle;
my $con_email="out.html";
my $fh = new FileHandle(">$con_email") or die $!;
$fh->print("Content-Type: text/html\n");
$fh->print("<html>");
$fh->print("<body>");
my $to = 'mbcdba@gmail.com';
my $from = 'noautoreply@gmail.com';
my $replyto = 'no_auto_reply@gmail.com';
my $subject = 'Test Email';
my $message = 'Simple <a href="http://mbc-dba.blogspot.in/2015/05/sendmail-utility-sending-mail-in-perl.html">script</a> to sending mail in perl.';
$fh->print("Reply-to: $replyto\n");
$fh->print("To: $to\n");
$fh->print("Cc: $to\n");
$fh->print("From: $from\n");
$fh->print("Subject: $subject \n\n");
$fh->print("$message");
$fh->print("</body>");
$fh->print("</html>");
system("/usr/lib/sendmail -t -oi < $con_email");
print "Email Sent Successfully\n";

Thats it..hope this will help you. Please comment here If you have any queries.

Thanks,
Chowdari 

Saturday, May 23, 2015

Sendmail Utility: Sending mail in PERL

SendMail is a lightweight, command line SMTP email client. If you are using Linux/Unix machine then you can use sendmail utility inside your Perl program to send email.

Here you can find simple script to send an email  with using sendmail utility.

#!/usr/bin/perl
$to = 'mbcdba@gmail.com';
$from = 'no_auto_reply@google.com';
$subject = 'Sample Test Email';
$message = 'This is sample email for testing PERL script';

open(MAIL, "|/usr/sbin/sendmail -t");

# Email Header
 print MAIL "To: $to\n";
 print MAIL "From: $from\n";
 print MAIL "Subject: $subject\n\n";
# Email Body
 print MAIL $message;

 close(MAIL);
 print "Email Sent Successfully\n";

Thats it..Hope this will help you.. :)

Thanks,
Chowdari

Thursday, May 7, 2015

Admrgpch Utility: Merge Patches using admrgpch

Admrgpch utility is used to merge multiple patches into a single one. This is useful when we have to apply many patches to reduce the patching time. This executable is located in AD_TOP/bin.

Consider below points for Admrgpch utility:

1) Admrgpch utility can't be used to merge patches of different releases, platforms or parallel modes.
2) AD patches and non AD patches can't be merged.
3) AD patches can be merged with other AD patches.
4) Merge any non-AD patch with any other non-AD patch.

Find below syntax to run AD merge patch:

admrgpch -s merge_source_directory -d merge_destination_directory -merge_name merge_driver_name
 
Here, create merge_source and merge_dest directories under /patch directory. Download the patches under /patch/merge_source directory. unzip those downloaded patches. In /patch/merge_dest directory will contains the merged patch driver file.

Demo for merging the 2 patches using admrgpch utility:

$ cd /patch

$ mkdir merge_source  merge_dest

$ ls
  merge_source  merge_dest

$ cd merge_source

Download the patches under merge_source directory 

$ ls
 16759426  17385991

Now run the below command to merge the patches.

$ admrgpch -s /patch/merge_source -d /patch/merge_dest -merge_name merged_patch

Executing the merge of the patch drivers
 -- Processing patch: merge_source/16759426
 -- Processing file: merge_source/16759426/u16759426.drv
 -- Done processing file: merge_source/16759426/u16759426.drv
 -- Done processing patch: merge_source/16759426
 -- Processing patch: merge_source/17385991
 -- Processing file: merge_source/17385991/u17385991.drv
 -- Done processing file: merge_source/17385991/u17385991.drv
 -- Done processing patch: merge_source/17385991

Copying files...

5% complete. Copied 47 files of 925...
10% complete. Copied 93 files of 925...
..................
......................
Character-set converting files...
  2 unified drivers merged.
Patch merge completed successfully
Please check the log file at ./admrgpch.log.
$

Now we can see u_merged_patch.drv driver file under merge_dest folder.

$ cd merge_dest
$ ls u_merged_patch.drv
  u_merged_patch.drv


Now apply the merged patch as a single patch using adpatch.

That's it..Hope this will help you.. :)

Thanks,
Chowdari

Some Most Popular Articles