Archive for the 'Erik’s Tech Notes' Category

Sending mail using Perl on Windows NET::SMTP

May 11th, 2010

NET:SMTP is a bit limited compared to Mail::Sender  or MIME::Lite.  For simple emails is is nice and simple.  It can also be handy when working on system where it is very difficult to make changes.  In my case I had 15 system with different version of Perl and make changes was difficult at best.

#!/perl/bin -w

use Net::SMTP;

$smtp = Net::SMTP->new( Host => “”,
Timeout => 20,
Debug   => 0,
) || die “SMTP failed”;

$smtp->mail(‘’);     # use the sender’s address here
$smtp->recipient(‘’, ‘’, { Notify => [‘FAILURE’,’DELAY’], SkipBad => 1 });   # Good
#        $smtp->to(‘’);        # recipient’s address
#        $smtp->to(‘’);        # recipient’s address
$smtp->data();                      # Start the mail

# Send the header.
$smtp->datasend(“Priority: Urgent\n”);
$smtp->datasend(“To:\, somebody.else\\n”);
$smtp->datasend(“Subject: Windows Perl Test Mail.\n”);

# Send the body.
$smtp->datasend(“Please reply if you recieved this email.  My name is Mud.\n”);
$smtp->dataend();                   # Finish sending the mail
$smtp->quit;                        # Close the SMTP connection

If you call the pl2bat utility on your Perl script, like this:

    C:\> pl2bat

it will produce a batch file, helloworld.bat. You can then invoke the script just like this:

    C:\> helloworld
     Hello, World!

You can invoke it on the command line like this:

cat myfile.txtYou can use it with I/O redirection (Windows 2000 SP3 and later) like this:

cat myfile.txt > newfile.txt cat myfile.txt | more

The best approach to use when writing Perl scripts that need to send email and also need to work on both UNIX and Windows systems is to use the Mail::Sender modules

You can install Mail::Sender by running:

  ppm install mail-sender

…at a command prompt. Documentation for using Mail::Sender is available here:

unix mail with perl


Free Anti Virus Software

April 8th, 2010

Avast –  Very good for rootkits.  Flexible antivirus tool.

rkhunter – tools used to find root kits.


iAntiVirus – Anti Virus for Mac.

Comodo – firewall fairly easy

Gdata – uses 2 A/V engines

Vipre – is a very slim software excellent for netbooks, and power users who prefer perforance.

BitDefender – possibly the best graphical interface for Linux.  Works with both Linux and Windows.  Can attach a windows disk to a Linux box then scan it.

Avira/Antivir – good CLI.  Can attach a windows disk to a Linux box then scan it.  Finds stuff that other tools do not.

MSE (Microsoft Security Essentials) – Anti Virus from Microsoft.  This should be the absolute minimum that is used on a Windows machine.  Simple, free effective.

ClamAV – Used for Mail Servers.

Dr.Web CureIt! – virus checker that you can put on a USB. This program is a small binary that you is manually launched.

ESET Smart Security Anti Virus and learning Firewall.

ZoneAlarm – Antivirus, Boot Authentication, encryption.  This program has come a long way but is no longer the light weight tool it once was.  Requires active participation.

VMWare commands

March 3rd, 2010

vmkfstools x (to change size)

vmkfstools -l (to clone)

service — mgmt -vmware stop

vmware-cmd <path> stop reset status start (affects start stop)

6 Ways to connect to ESX Server

March 3rd, 2010

 – Console

–  Remote SSH

– Web Access

– Virtual Infrastructure Client (VSphere)

– Virtual Center – Entire Infrastructure

– RCLI (Remote command Line Interface)

Free Tools / Downloads

March 2nd, 2010

Ad-Aware Free – Find and remove SpyWare

Audacity – Record and edit Sound

BitTorrent – file Sharing

Dropbox – 2gb of online data – Conference call service

IMDb – Movie Review Database – Office Sweet

Gimp – Image Editor

Putty – xterm for Windows

Keypass – Password Safe

Password Safe –  the name says it all

superantispyware – find and remove spyware

 ccleaner – cleans unused files, web traffic etc

Fences – Organize Windows Desktop Icons

defraggler – Defrag Windows

UltraDefrag - Defrag Window

MSE – Remove Spy Ware

BGInfo – System information on Windows Desktop

Solaris – format

February 11th, 2010

 # format
Searching for disks…done
0. c0t0d0 <drive not available: formatting>


# format -Mm
may be helpful as this reports additional messages about what is happening.

Get a list of disks

# format < /dev/null or echo “\n” | format

format non destructive commands
disk, current, defect, verify, save, inquiry

format destructive commands
type, partition, format, repair, label, analyze, backup

formating using another disk
# prtvtoc /dev/rdsk/c0t0d0s2 | fmthard -s – /dev/rdsk/c0t2d0s2

Install boot block
# installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c0t2d0s0

A fairly typical layout is

0. /
1.  swap
2. whole disk
3.  /var
4. /data

If the system has has a database locally and there is a need for a bit of extra speed then /data can always be put on the faster part of the disk. Not to many systems swap much anymore since there is the ability to put in as much memory as is needed. Although if needed a seperate filesystem can be created for a swap partition.
0. /data
1. /
2. whole disk
3. /swap
4. /var

x86 / Linux raid

September 1st, 2009

Note not “hardware” raid cards for pc type machines actually do hardware raid.  Most of the cheaper raid controllers are doing a form of software raid that uses their driver and the system bios.

 At that point it is probably best just to use the OS to do the raid and skip the extra.

 If it states somewhere on the box  (e.g., 3w-xxxx, 3w-9xxx, aacraid, cciss, dac960, dpt_i2o, gdth, ips, megaraid, megaraid2, megaraid_mbox aka megaraid-newgen, mpt*) then there is a good chance that it is true hardware raid.

A couple of good pages

This page has a good list of what is and what is not true hardware raid.

A site that talks about what they are calling fakeraid.

This is a good break down on what is the difference between fakeraid and hardware raid.

I have cut and pasted this article below on the off chance this page ever disappears.  I do not do this often but on occasion I put in a link to a quality article then years later go back and it is gone.  Just want to make sure I keep this one.

 .  Be sure to check out Mark’s Blog.  It has quite a bit of real good stuff in it.  I ended up getting lost in there for a bit.  Good Stuff.


SATA RAID Cards (Linux/Windows), What you Should Know About Fake RAID Cards

| 1 TrackBack

I recently had a rude awakening regarding many of today’s RAID cards; come to find out most of today’s RAID controllers are not actually “hardware RAID” cards like you might expect.  A few days ago, I went to Fry’s and picked up a relatively cheap SATA 4-Channel RAID card (SC-SA4R12-S2) by SIIG.  I brought it home, unpacked it, and plugged it into my Linux box.  Everything was working well, except that the raw disks connected to the RAID controller were exposed under /dev:


I found this strange, because I used the controller’s Option ROM configuration utility to build a RAID-1 volume (a mirror) of the two SATA drives connected to the controller.  Assuming my RAID card drivers were installed, I was expecting to see only one device file for the “virtual RAID array” that I just created (e.g., /dev/cciss/*).  Continue reading to see what’s actually going on.

In my past life with HP-UX, I’ve worked on the HP-UX CISS Smart Array RAID driver.  Using an HP-UX Smart Array RAID solution, or a CCISS Linux Smart Array RAID solution, the OS driver only sees RAID arrays, and uses RAID-specific commands to read/write data.  The individual disks themselves are not actually exposed to the OS.  This is true hardware RAID.  If my new SATA RAID card was actually a true hardware RAID controller, I wouldn’t see both disk device files under /dev.  Instead, I would see a single device file pointing to the mirrored RAID volume.

So what exactly is going on anyways?  I thought my SATA RAID card is actually a hardware RAID card?  Turns out, it’s not.  I dug around looking for answers, and come to find out, many non-enterprise level RAID cards sold today are actually “fakeraid” cardsThese “fakeraid” cards use the OS driver and on-board flash BIOS to provide 100 percent of the RAID capability.  My cheap SATA 4-Channel RAID card (SC-SA4R12-S2) by SIIG is nothing more than a fake; it’s a bare non-RAID SATA controller that relies on the OS driver for most of the RAID operations.  That basically defeats the purpose of buying a hardware RAID card in the first place; the whole point of using a real hardware RAID controller is to offload the RAID processing from the host to the controller itself.

In any event, my SATA 4-Channel RAID card (SC-SA4R12-S2) by SIIG was only $40, so I guess I got what I paid for!  If you suspect your RAID card isn’t a real hardware RAID controller, you can check with Linuxmafia.

If you want to setup a software RAID volume on Linux, read my HOWTO guide.



Windows – Memory/Performance Troubleshooting

August 19th, 2009

Process Explorer:

Performance Monitor:;en-us;325558


RedHat – NIC Status

August 18th, 2009

ifconfig -a in RedHat does not provide link status sooooo.  After a bit of digging it turns out there is a cool tool that will.

# /sbin/ethtool eth0
Settings for eth0:
Supported ports: [ TP ]
Supported link modes:
10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Supports auto-negotiation: Yes
Advertised link modes:
10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Advertised auto-negotiation: Yes
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: g
Wake-on: d
Link detected: yes

Ultra2 Backup Boot Disk Script

August 18th, 2009

This script is a bit crude but it does work if the system is not real busy.  Another solution is to use SVM and mirror the disks.  The problem there however is; if a disk is lost and the system goes down it will not come up since SVM needs a quarum (over half) with the metadb’s. 

 I use the below scipt plus dump a flar to another system.  I really need to convert this disk to cpio.

# This script backs up the primary to secondary hard disk on an ultra class machine.
# c0t0d0 is the primary disk
# c0t1d0 the secondary disk
# s0 is / s3 is /var s7 is /work.

# This partitions the secondary disk to match the primary disk of same geometry.
prtvtoc /dev/rdsk/c0t0d0s2 | fmthard -s – /dev/rdsk/c0t1d0s2

# Make backup directory mount points if not present.
if (! -d /root1) mkdir /root1
if (! -d /var1) mkdir /var1
if (! -d /work1) mkdir /work1

# Unmount the partitions of secondary disk if they are mounted.
if ( -e /root1/lost+found) umount /dev/dsk/c0t1d0s0
if ( -e /var1/lost+found) umount /dev/dsk/c0t1d0s3
if ( -e /work1/lost+found) umount /dev/dsk/c0t1d0s7

# Newfs partitions of the secondary disk.
newfs -v /dev/rdsk/c0t1d0s0 < /dev/null
newfs -v /dev/rdsk/c0t1d0s3 < /dev/null
newfs -v /dev/rdsk/c0t1d0s7 < /dev/null

# Mount secondary disks
mount /dev/dsk/c0t1d0s0 /root1
mount /dev/dsk/c0t1d0s3 /var1
mount /dev/dsk/c0t1d0s7 /work1

# Dump from primary to seconday
ufsdump 0sf 5000000 – / | (cd /root1; ufsrestore rf – )
ufsdump 0sf 5000000 – /var | (cd /var1; ufsrestore rf – )
ufsdump 0sf 5000000 – /work | (cd /work1; ufsrestore rf – )

# Install boot block on secondary disk
installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c0t1d0s0

# Update motd
echo `uname -rsvi`” Primary disk” > /etc/motd
echo “Backup copy on “`date` >> /etc/motd
echo `uname -rsvi`” Secondary disk” > /root1/etc/motd
echo “Backup copy on “`date` >> /root1/etc/motd

# Change /root1/etc/vfstab to enable boot disk1
sed ‘s/c0t0/c0t1/g’ /etc/vfstab > /root1/etc/vfstab

# Unmount backup disk.
umount /dev/dsk/c0t1d0s0
umount /dev/dsk/c0t1d0s3
umount /dev/dsk/c0t1d0s7

Next »