Pages

Wednesday, March 30, 2016

Send email using power shell from Windows Machine

Prerequisites:-

SMTP relay server domain name of IP address
SMTP relay server port reach-ability
SMTP relay server credentials

Save content specified below in sendemail.ps1 file

##############################################################################
$From = "YourEmail@gmail.com"
$To = "AnotherEmail@YourDomain.com"
$Cc = "YourBoss@YourDomain.com"
$Attachment = "C:\temp\Some random file.txt"
$Subject = "Email Subject"
$Body = "Insert body text here"
$SMTPServer = "smtp.xyz.com"
$SMTPPort = "587"
Send-MailMessage -From $From -to $To -Cc $Cc -Subject $Subject `
-Body $Body -SmtpServer $SMTPServer -port $SMTPPort -UseSsl `
-Credential (Get-Credential) -Attachments $Attachment
##############################################################################

Execute the power shell script as below,
./sendemail.ps1 
Regards,
Sandeep Panchal.

Thursday, March 10, 2016

Check Presence of Perl Modules on linux

To check list of Perl modules installed on a Linux server below command can be helpful,

perl -MFile::Find=find -MFile::Spec::Functions -Tlw -e 'find { wanted => sub { print canonpath $_ if /\.pm\z/ }, no_chdir => 1 }, @INC' 

Below is sample output of command.

perl -MFile::Find=find -MFile::Spec::Functions -Tlw -e 'find { wanted => sub { print canonpath $_ if /\.pm\z/ }, no_chdir => 1 }, @INC' 

/usr/lib64/perl5/Data/Dumper.pm
/usr/lib64/perl5/XML/LibXML.pm
/usr/lib64/perl5/XML/LibXML/SAX.pm
/usr/lib64/perl5/XML/LibXML/Boolean.pm
/usr/lib64/perl5/XML/LibXML/NodeList.pm

/usr/lib64/perl5/XML/LibXML/Number.pm

Just to have understanding about the output, Say you are looking for module "Data::Dumper" then you should be able to see presence of file as "......../Data/Dumper.pm" as seen in above example.

Below is the quick command to  check for presence of a specific module.

perl -MFile::Find=find -MFile::Spec::Functions -Tlw -e 'find { wanted => sub { print canonpath $_ if /\.pm\z/ }, no_chdir => 1 }, @INC' |egrep -i 'data/dumper'

/usr/lib64/perl5/Data/Dumper.pm