I must be perl-tarded but here goes.
i am trying to setup and send a simple email and fooey no emails working yet, I have replaced the servername and username password stuff, they did have valid values what I do get is the number of processes and no errors aside from global variable $msg requires explicit package name.
I am on a windows system 2003 server, using mime:lite and trying to use smtp but probably doing it wrong here is my code. ok you can give me a hard time if you want I just want to understand what is wrong aside from the complaining about that variable which is because of warnings and strict being on, cause everybody says to use warnings and strict.
my shebang line has -w trust me it does..
I also want to loop this check so that it runs for several hours
once an hour this should do for about 30 hours right?
use Win32::Process::List;
use Mail::Sender;
use MIME::Lite;
use strict;
my $numloops=0;
my $timer=6000;
while($numloops>30){
$numloops++
sleep $timer;
my $P = Win32::Process::List->new();
if($P->IsError == 1)
{
print "an error occured: " . $P->GetErrorText . "\n";
}
my %list = $P->GetProcesses();
my $anz = scalar keys %list;
print "Anzal im Array= $anz\n";
my $count = 0;
foreach my $key (keys %list) {
# $list{$key} is now the process name and $key is the PID
#print sprintf("%20s has PID %10s", $list{$key}, $key) . "\n";
$count++;
}
print "Number of processes: $count\n";
my $process = "mmdrv.exe";
my %hPIDS = $P->GetProcessPid($process);
print keys (%hPIDS) . "\n";
if(%hPIDS) {
foreach (keys %hPIDS) {
print "$_ has PID " . $hPIDS{$_} . "\n";
}
} else
{
print "Process(s) not found\n";
#exit;
my $test= MIME::Lite->send('smtp', "servername@mydomain.com",
AuthUser=>"$username",AuthPass=>"$Pass" );
my $msg = MIME::Lite->new(
From =>'validemail@mydomain.com',
To =>'validemail@mydomain.com',
Cc =>'some@other.com, some@more.com',
Subject =>'Hello testing email from perl heartbeat monitor sc
+ript',
Data =>"Loadrunner is running!"
);
}
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.