So I have two script one in vb and one in perl. My perl script is to get the information from a file and parse it into the datase and also open a socket connection to my vb script and forward the information to send out email and paging notification. Now i setup my perl script to run as a service and do the parsing automatically. But when i try to create the socket connection to my vb...sometime it would work right and then the service stop. Or sometime if i stop and start my vb script it would work the first file but for the second file it doesnt n cause the service to stop. I'm using WIN32-Daemon as my service.
foreach my $filename ( readdir( DIR ) )
{
my $filepath = "$scan_dir\\$filename";
if ( $filename =~ /\.txt$/i ) {
my ($variable)=Read_File( $scan_dir, $filename );
Scan_File($variables);
my $status=Socket($variable,$sock);
}
else { # get rid id miscellanous files in this directory
unlink "$scan_dir\\$filename" or print ERROR "can't unl
+ink $scan_dir\\$filename $!";
}
}
Now if i comment out the "my $status=Socket" it work perfectly. and it not commend out sometime the notifcation would work other it cause the service to stop. Any Idea on what might be causing the problem?
sub Socket {
my ($variable, $sock)=@_;
if ($alarmtype =~ "WARNING") {
$alarmtype = "NOTIFICATION";
}
elsif ($alarmtype =~ "HALT") {
$alarmtype = "SHUTDOWN";
}
my $msg= "$alarmtype\r\n$eqpid\r\n$eqpid-$chamber\r\nMW\r\nTriant
+Parameter Out of Bound. \r\nTCOM:\r\nN\r\nAlarmType='$alarmtype' $sen
+sor on recipe $recipe is out of bound. Signal_Level = $signal_level L
+ower = $alarm_lower_limit Upper = $alarm_upper_limit Code = $code \r\
+nI\r\nSTOP\r\nPHOT\r\n";
sendToLog ("TCOM socket: $msg") ;
$sock->send($msg );
return ("TRUE");
}
This is my socket sub