Batch Script: Send Email


sendmail is a handy tool that can be used in batch script to send email. 1) Configure your SMTP settings in the sendmail.ini file. Following is a sample to use Gmail: [sendmail]; you must change mail.mydomain.com to your smtp server,smtp_server=smtp.gmail.com ; smtp port (normally 25)smtp_port=465 ; error logerror_logfile=mail_error_log.txt ; Gmail username and passwordauth_username=xxxxxx@gmail.comauth_password=*********** ; the … Continue reading Batch Script: Send Email

Perl: Send Email


A Perl sample code to send a file’s content by either Gmail or local SMTP. #!/user/bin/perl -w use strict;use Net::SMTP; # used by local SMTPuse Net::SMTP::TLS; # used by Gmail # Read the file content from error_logopen( my $error, "<error_log");my @log = <$error>;# If error_log is empty, then do nothingif (scalar(@log) == 0) {    close … Continue reading Perl: Send Email

Perl: Read Excel Cell Value


A sample code to read excel cell value by using Spreadsheet::ParseExcel module. #!/user/bin/perl -w use strict;use Spreadsheet::ParseExcel;#Parse excel filemy $parser = Spreadsheet::ParseExcel->new();my $workbook = $parser->parse("test.xls"); #Get cell value from excel sheet1 row 1 column 2my $worksheet = $workbook->worksheet('sheet1');my $cell = $worksheet->get_cell(1,2); # Print the cell value when not blankif ( defined $cell and $cell->value() ne … Continue reading Perl: Read Excel Cell Value

Bash: Log File Archive Script


There are some logs files are in such format: 20120130-174201-130947.log. I created two bash scripts to archive them by year/month/day: The first one is based on the log file creation date, the other one is based on the time stamp within the file name. #Backup Script1: Use modification date of the file#!/bin/bash #Define the Log … Continue reading Bash: Log File Archive Script

How to Manually Remove a Damaged Hyper-V Virtual Machine


If you see such errors in the Hyper-V event log, and fail to delete the damaged virtual machine in the Hyper-V manager. Just go to ‘C:\ProgramData\Microsoft\Windows\Hyper-V\Virtual Machines’ and delete the file which filename is  the same as the virtual machine ID. After that, the damage virtual machine should be gone in your Hyper-V manager. If … Continue reading How to Manually Remove a Damaged Hyper-V Virtual Machine