Well good question.... I am not sure. How would I find that out?
I am very new to Perl. The person who did this is gone and I am attempting to get it working right.
Thank you for the help.
Main Topics
Browse All TopicsGood morning all....
I have been learning Perl for about 2 months now and I guess I am getting there as much as I can however I am really stuck. I have a Perl script called postEvent.pl which uses a package called event.pm. PostEvent.pl depends on a meithod inside event.pm called isSuccess to tell the user if the message sent was a success.
For some reason I keep getting....
"Problems sending message to Tivoli"
Which is coming from...
if ($event->isSuccess()) {
&info("Message sent to Tivoli, $flags{'m'}");
} else {
&error("Problems sending message to Tivoli, ", $event->getStatusMsg);
}
In postEvent.pl.
The problem is that the message is in fact a success, for some reason its just not getting the message that it was a success from the event.pm package and I am not sure why. I am listed both sets of source code here in hopes that somebody can tell me what I am doing wrong and show me. I have been stuck on this for 2 days now ;-(
Thank you.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Normally, a program will return 0 as the exit code if it executed successfully.
The $event->isSuccess() method returns the exit code of the program that was run in the system() call.
The problem/bug is that the name of that method is misleading because in boolean context, 0 is false which is opposite of the implied meaning of the method's name.
The easiest "fix/workaround" would be to test the value returned, like this:
I just gave that a try but same results....
0[Thu Oct 8 13:27:24 2009] [ERROR] Problems sending message to Tivoli,
ottocat:/lcl/apps/esm/bin>
However I added a print ("$this->{'STATUS'}");
Just before the....
return $this->{'STATUS'};
In Event.pm to see the value its attempting to return and as you can see from the output above it is in fact 0.
I REALLY need to find a way to do this through from making the change in Event.pm.
postEvent.pl is deployed on a ton of servers and they do not want us to change that... So I really need to figure out how to pass the success state from Event.pm to the current code of PostEVent.pm
Thanks for the help
Ok but using the code you stated above and using the print command I can see that it is returning 0 yet the code....
if ( $event->isSuccess() == 0 ) {
info("Message sent to Tivoli, $flags{'m'}");
} else {
error("Problems sending message to Tivoli, ", $event->getStatus);
}
Still reported....
0[Thu Oct 8 13:27:24 2009] [ERROR] Problems sending message to Tivoli,
Is it because the 0 is right next to the time stamp? Just taking a guess here.
Yes, replaced what I had with....
if ( $event->isSuccess() == 0 ) {
info("Message sent to Tivoli, $flags{'m'}");
} else {
error("Problems sending message to Tivoli, ", $event->getStatus);
}
Output....
0
[Thu Oct 8 14:10:41 2009] [ERROR] Problems sending message to Tivoli,
ottocat:/lcl/apps/esm/bin>
Well the output say [ERROR] so I would guess the error sub.
The only explanation for those results would be that the script you're executing is not the same script that you edited.
$event->getStatus will return the exit code that was stored in $this->{'STATUS'}
The output you received shows the the value in $this->{'STATUS_MSG'} which can be retrieved via $event->getStatusMsg which is exactly what you were doing in the code in your original post.
Lines 59 - 63
All I did was comment out this code....
# if ($event->isSuccess()) {
# &info("Message sent to Tivoli, $flags{'m'}");
# } else {
# &error("Problems sending message to Tivoli, ", $event->getStatusMsg);
# }
And past this code.....
if ( $event->isSuccess() == 0 ) {
info("Message sent to Tivoli, $flags{'m'}");
} else {
error("Problems sending message to Tivoli, ", $event->getStatus);
}
That was it. Seems to me like it should work if I follow correctly what you are saying.
I corrected the conditional statement i.e. I set it to: if ( $event->isSuccess() == 0 ) {
I then ran several tests and all returned the results I expected. I was unable to duplicate the problem you describe.
[root@fc4dev EE]# ./postevent.pl
##########################
Output being sent to postzmsg....
/lcl/apps/esm/bin/postzmsg
##########################
sh: /lcl/apps/esm/bin/postzmsg
[Thu Oct 8 15:13:59 2009] [ERROR] Problems sending message to Tivoli,
In the next example out, I changed the system call to: $this->{'STATUS'} = system('ls > /dev/nul');
[root@fc4dev EE]# ./postevent.pl
##########################
Output being sent to postzmsg....
/lcl/apps/esm/bin/postzmsg
##########################
[Thu Oct 8 15:23:35 2009] [INFO] Message sent to Tivoli,
Voodoo:
I understand where you are coming from, it's hard to work on someone else's code.
When did these problems start, has this script worked before?
Or are these problems based on new additions you or someone else added to the script and/or package?
if it has worked before and just stopped working recently, what has changed?
If Fishmonger can't duplicate the problem then it's making me think something else is going on here.
What version of perl are you both using? The same one?
What version of OS are you both using? The same one?
Well figured out why the code changes were not working....
Its because if you execute it like this....
./postEvent.pl it runs the local...
But if you say postEvent.pl the pathe is defined so it was never running the one I was trying to fix!!! :-/
But anyway all the changes need to take place from the event.pm package as we can not change the postEvent.pl script. This all worked before but they made some changes to the event.pm file.
Thank you for trying.
Business Accounts
Answer for Membership
by: FishMongerPosted on 2009-10-08 at 08:15:37ID: 25526375
What was the exit code of the system call in the $event->postEvent method and what was returned in the $event->getStatusMsg call?
The $event->getStatusMsg call at this point is probably of no use since the $event->postEvent method didn't set it.