473,320 Members | 1,612 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Using perl to check services

Hi,

I wrote this little script to check to see if our Lotus Notes servers are
running, and from the command line it works fine if I type perl
notescheck.pl

When I invoke the script from a web page I get an error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable
to complete your request.

Please contact the server administrator, yo*@example.com and inform them of
the time the error occurred, and anything you might have done that may have
caused the error.

More information about this error may be available in the server error log.

Here is the script:

#!/usr/bin/perl -w
#use strict;
use IO::Socket;

$hostName = notesserver;
my $host = shift || $hostName;
my $port = shift || 25;
my $sock = new
IO::Socket::INET(PeerAddr=>$host,PeerPort=>$port,P roto=>'tcp');
if($sock)
{
print "<script>
alert(\"Server notesserver is running...\");
history.back();
</script>";
exit;
}
else
{
print "<script>
alert(\"Server notesserver appears to be down...\");
history.back();
</script>";
exit;
}
close $sock or die "close: $!";

When I run the script from the console (perl notescheck.pl) I get the
following:

<script>
alert("Server RSLNM02 is running...");
history.back();
</script>[root@rts cgi-bin]#
....which tells me the script is running fine.

Heres the code from the web page:

<form action="/cgi-bin/notescheck.pl" method="post">
<input type="submit">

Can anyone tell me why this doesn't work?

Thanks,
Jason


Jul 19 '05 #1
3 7838
In article <qV*********************@news20.bellglobal.com>, Jason Miles
<ry*****@bellnexxia.net> wrote:
Hi,

I wrote this little script to check to see if our Lotus Notes servers are
running, and from the command line it works fine if I type perl
notescheck.pl

When I invoke the script from a web page I get an error:
[server error snipped]

Here is the script:

#!/usr/bin/perl -w
#use strict;
use IO::Socket;

$hostName = notesserver; ^^^^^^^^^^^ bareword?
my $host = shift || $hostName;
my $port = shift || 25;
my $sock = new
IO::Socket::INET(PeerAddr=>$host,PeerPort=>$port,P roto=>'tcp');
if($sock)
{
print "<script>
alert(\"Server notesserver is running...\");
history.back();
</script>";
exit;
}
else
{
print "<script>
alert(\"Server notesserver appears to be down...\");
history.back();
</script>";
exit;
}
close $sock or die "close: $!";


Is this the code you ran? It contains a bare-word 'noteserver', which
should probably be a variable or a string, but you do not show how it
gets the value 'RSLNM02'. You would have noticed this if you had left
the 'use strict;' line uncommented. Please do not ask people to find
problems that the compiler can easily find.

What is the error message in the server log? (You did look for the
error message in the server log, didn't you?)

Try

perldoc -q 500

for more help, particularly about the proper newsgroup for posting
about web server questions (your Perl program looks OK, except for the
noted error).

Finally, this newsgroup is defunct. Try comp.lang.perl.misc in the
future for Perl questions.
Jul 19 '05 #2
On Tue, 06 Apr 2004 13:27:26 -0700, Jim Gibson wrote:
In article <qV*********************@news20.bellglobal.com>, Jason Miles
<ry*****@bellnexxia.net> wrote:
Hi,

I wrote this little script to check to see if our Lotus Notes servers
are running, and from the command line it works fine if I type perl
notescheck.pl

When I invoke the script from a web page I get an error:


[server error snipped]

Here is the script:

#!/usr/bin/perl -w
#use strict;
use IO::Socket;

$hostName = notesserver;

^^^^^^^^^^^ bareword?
my $host = shift || $hostName;
my $port = shift || 25;
my $sock = new
IO::Socket::INET(PeerAddr=>$host,PeerPort=>$port,P roto=>'tcp');
if($sock)
{
print "<script>
alert(\"Server notesserver is running...\");
history.back();
</script>";
exit;
}
else
{
print "<script>
alert(\"Server notesserver appears to be down...\");
history.back();
</script>";
exit;
}
close $sock or die "close: $!";

Is this the code you ran? It contains a bare-word 'noteserver', which
should probably be a variable or a string, but you do not show how it
gets the value 'RSLNM02'. You would have noticed this if you had left
the 'use strict;' line uncommented. Please do not ask people to find
problems that the compiler can easily find.

What is the error message in the server log? (You did look for the error
message in the server log, didn't you?)

Try

perldoc -q 500

for more help, particularly about the proper newsgroup for posting about
web server questions (your Perl program looks OK, except for the noted
error).

Finally, this newsgroup is defunct. Try comp.lang.perl.misc in the
future for Perl questions.


This may be a stupid question, other then the bare word, isn't this script
also missing the content type, so the output is interpreted by the browser
as a a web page?
Jul 19 '05 #3
Yes, that's exactly what the problem was. Thanks for your replies...

"James T" <turajb@_NOSPAM_hoflink.com> wrote in message
news:pan.2004.04.07.03.28.06.765573@_NOSPAM_hoflin k.com...
On Tue, 06 Apr 2004 13:27:26 -0700, Jim Gibson wrote:
In article <qV*********************@news20.bellglobal.com>, Jason Miles
<ry*****@bellnexxia.net> wrote:
Hi,

I wrote this little script to check to see if our Lotus Notes servers
are running, and from the command line it works fine if I type perl
notescheck.pl

When I invoke the script from a web page I get an error:


[server error snipped]

Here is the script:

#!/usr/bin/perl -w
#use strict;
use IO::Socket;

$hostName = notesserver;

^^^^^^^^^^^ bareword?
my $host = shift || $hostName;
my $port = shift || 25;
my $sock = new
IO::Socket::INET(PeerAddr=>$host,PeerPort=>$port,P roto=>'tcp');
if($sock)
{
print "<script>
alert(\"Server notesserver is running...\");
history.back();
</script>";
exit;
}
else
{
print "<script>
alert(\"Server notesserver appears to be down...\");
history.back();
</script>";
exit;
}
close $sock or die "close: $!";

Is this the code you ran? It contains a bare-word 'noteserver', which
should probably be a variable or a string, but you do not show how it
gets the value 'RSLNM02'. You would have noticed this if you had left
the 'use strict;' line uncommented. Please do not ask people to find
problems that the compiler can easily find.

What is the error message in the server log? (You did look for the error
message in the server log, didn't you?)

Try

perldoc -q 500

for more help, particularly about the proper newsgroup for posting about
web server questions (your Perl program looks OK, except for the noted
error).

Finally, this newsgroup is defunct. Try comp.lang.perl.misc in the
future for Perl questions.


This may be a stupid question, other then the bare word, isn't this script
also missing the content type, so the output is interpreted by the browser
as a a web page?

Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: bezeee | last post by:
At my work we are in the process of building a tool to test an XML based API. Basically, XML in and XML out over http. Currently, there are two engines that do all of the schema validations, xml...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
0
by: Peter Conrey | last post by:
I have a perl web service (using SOAP::Lite) with a method called "Detail" that returns a strucure (hash reference to be exact). It works fine when consumed by a Perl client, but when I try to...
2
by: kelly | last post by:
Hi, I don't have a code to show you, what I need are references or algorithms so that I'm in a right track. By the way, thanks for introducing me the array or arrays. Now I can continue my...
3
by: Jay-nospam | last post by:
Hi there, I am having trouble getting an ASP.NET web application to connect to another computer and passing the proper credentials and I hope someone can help me. I have a stand-alone Windows...
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
1
by: pchaw | last post by:
I try to develop a demo, which client in Perl will try to call the web services I wrote in C#. I've no knowledge in Perl, but as I refer to online forum, I try to follow their example but return no...
1
by: parimalb | last post by:
Hi All, I want to pass an array argument to the java webservice from perl client using SOAP::LITE package. Please let me know if anyone knows about this. The web method declaration in java is...
1
by: spatro | last post by:
Hi, I am trying to install DBD::mysql using the CPAN and I am facing the following error: cpan> install DBD::mysql CPAN: Storable loaded ok Going to read /root/.cpan/Metadata Warning:...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.