• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 384
  • Last Modified:

Getting an "Internal Service Error" on one server, but not on another.

Weird problem (for me).

Here's the script I am running.

==============================

#!/usr/bin/perl

$mailprog = '/usr/lib/sendmail';

$recipient = 'ggordon@garymgordon.com';

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
    {
    ($name, $value) = split(/=/, $pair);
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $FORM{$name} = $value;
    }


open (MAIL, "|$mailprog $recipient");
print MAIL "To: $recipient\n";
print MAIL "From: $FORM{'Email_Address'}\n";
print MAIL "Subject: Bishop Kelley Online Form\n\n";

foreach $pair(@pairs)
{
    ($name,$value)=split(/=/,$pair);
    $value=~ tr/+/ /;
    $name=~ tr/+/ /;
    $value=~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
    $name=~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
    $FORM{$name}=$value;
print MAIL "$name:\t $value\n\n";
}

close(MAIL);

print "Location: http://bkelleyhs.org/dvlp_cc_thnkupage.htm\n\n";

============================

I set permissions on the Linux server to 755.
It is working fine when I run it from a server (garymgordon.com), but when I try to run it from a Linux server on (bkelleyhs.org), I get an internal server error.

The code is identical.
Permissions are the same.
Uploaded the script using FTP in Ascii mode.

I don't understand what could cause this to occur.

I would greatly appreciate some thoughts.  Maybe I am missing something stupid.

Help????

Gary


Gary M. Gordon
ggordon@garymgordon.com

0
Gary Gordon
Asked:
Gary Gordon
  • 16
  • 10
  • 8
  • +1
1 Solution
 
kanduraCommented:
two suggestions:
1. start using the CGI module
2. check the call to open() for failure:

    open MAIL, "|$mailprog $recipient" or die "Error opening pipe to sendmail: $!";
0
 
ahoffmannCommented:
> Uploaded the script using FTP in Ascii mode.
upload in binary mode! enshure it is UNIX format if the server is UNIX (or Linux)

Does /usr/bin/perl exist on the server?
Check your error logs
0
 
kanduraCommented:
ahoffmann,
> upload in binary mode!

why? perl scripts are text, or am i missing something?
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
ahoffmannCommented:
some ftp server and/or clients have different meaning about the definition of "ascii", unfortunately ...
so if you enshure the format local and transfer it it as binary, you can be shure that the file is the same format remote as local
0
 
Gary GordonWebsite Developer, Designer, SEO and Online Marketing specialist.Author Commented:
Well ...
1.   /usr/bin/perl does exist.
I was able to run a simple TEST perl script to display Hello World!  So, it is finding Perl.

2.  I uploaded in Ascii mode.

3.  As I said, it is working fine when I upload it to one Linux server, but not on another.

Additional notes regarding the server:

PATH TO SENDMAIL /usr/sbin/sendmail
                             /usr/lib/sendmail
                             /usr/share/sendmail
 
PATH TO PERL       /usr/bin/perl

PERL VERSION      5.6 (linux OS compile version)  

DOCUMENT_ROOT /usr/local/httpd/htdocs

GATEWAY_INTERFACE   CGI/1.1

HTTP_HOST         bkelleyhs.org

PATH                   /sbin:/bin:/usr/sbin:/usr/bin
 

Is there a problem with the PATH that is listed?

Is there any problem with the HTTP_HOST (being that it doesn't include www before the bkelleyhs.org?

Any other thoughts?

Gary








0
 
Gary GordonWebsite Developer, Designer, SEO and Online Marketing specialist.Author Commented:
RE the comment:  

some ftp server and/or clients have different meaning about the definition of "ascii", unfortunately ... so if you enshure the format local and transfer it it as binary, you can be shure that the file is the same format remote as local

I am using the same FTP client (WS_FTP PRO) to upload to both servers.  One is fine, the other is giving me this error.  I uploaded both using ASCII.

I wasn't sure what you meant by your comment.

I thought since Perl scripts are TEXT, that they should be uploaded using ASCII (not Binary).  Are you telling me to upload the .cgi files as Binary?  And if so, why?  That confuses me.

Thanks,
Gary
0
 
ahoffmannCommented:
binary vs.ascii mode simply tells the server to use the data as is, while in ascii mode the server converts, somehow
and that "somehow" may be a problem
Again: enshure that your text file is in proper format before uploading, then upload in binary. That works always.

Please check your error log, that should give you the reason why it failed
0
 
TintinCommented:
Plenty of good advice about FTP and ascii/binary mode, so here is an updated version of your script using the CGI module.

#!/usr/bin/perl
use strict;
use CGI::Carp qw(fatalsToBrowser);
use CGI;

my $recipient = 'ggordon@garymgordon.com';
my $mailprog = '/usr/lib/sendmail';

my $q = new CGI;
my %p = $q->Vars;

open MAIL,"|$mailprog -oi -t" or die "Can not run $mailprog $!\n";

print MAIL <<EOF;
To: $recipient
From: $p{'Email_Adress'}
Subject: Bishop Kelley Online Form

EOF

foreach my $key (keys %p) {
  print MAIL "$key $p{$key}\n";
}

close MAIL;

print $q->redirect('http://bkelleyhs.org/dvlp_cc_thnkupage.htm');
0
 
Gary GordonWebsite Developer, Designer, SEO and Online Marketing specialist.Author Commented:
ahoffman,

Ok.  I did this, but still get the error.

PS:  The error_log had:

Execution of /usr/local/httpd/cgi-bin/bishopkelley_email.cgi aborted due to compilation errors.
[Tue Apr 19 17:37:25 2005] [error] [client 68.45.81.65] Premature end of script headers: /usr/local/httpd/cgi-bin/bishopkelley_email.cgi


Now what?

Again .. part of my question is (aside from getting this to work) is .. WHY would these errors occur on one server but not the other?  Seems weird.

Help?

Gary
0
 
Gary GordonWebsite Developer, Designer, SEO and Online Marketing specialist.Author Commented:
I even tried the new script and get the same Server error.

Could it have something to do with the HTML page?  Maybe there is something there that is causing the issue. ????

You can see it at:

http://bkelleyhs.org/bkhs_ccsurvey05_bkup.htm

Gary
0
 
kanduraCommented:
garymgordon,
> aborted due to compilation errors.

better check those, then!

log in to the server (with ssh or telnet), and run

    perl -c bishopkelley_email.cgi

and tell us the result of that. or fix the errors straightaway :)
0
 
Gary GordonWebsite Developer, Designer, SEO and Online Marketing specialist.Author Commented:
Well, I just ran a test .. by including some print statements and found the script broke when it was trying to connect to sendmail (I think).  Here is what it said (when it broke), but I don't know how to fix this.

ERROR MESSAGE:

/etc/mail/submit.cf: line 430: readcf: option RunAsUser: unknown user smmsp: No such file or directory /etc/mail/submit.cf: line 449: readcf: option TrustedUser: unknown user smmsp: No such file or directory Mail submission program must have RunAsUser set to non root user

How can I fix this?  I need very specific help, since I don't know what I am doing at this point.  haha

:-)
Gary
0
 
ahoffmannCommented:
> aborted due to compilation errors.
means that your script has syntax errors, most likely 'cause a module is missing
do as kandura suggested: login to the server and test the script from command line
0
 
kanduraCommented:
garymgordon,
> ERROR MESSAGE:

> /etc/mail/submit.cf: line 430:

Take the full text of that error message to your system administrator. Your sendmail is not properly configured, and that is why your script failed when it tried to send mail.

Your script itself is apparently running okay, although you might want to add a more user-friendly message when connecting to sendmail fails.
0
 
Gary GordonWebsite Developer, Designer, SEO and Online Marketing specialist.Author Commented:
kandura,

So they can fix this, since I doubt they know what to do, can you possibly explain how they might go about re-configuring sendmail?

What steps should they take to test it?
How can they tell what it is about send mail that isn't configured properly?
I am guessing that I will need to tell them "exactly" what to do in order to debug the configuration problem with sendmail .. and how to fix it?
Is there a site that would have "step by step" instructions on how to re-configure it properly?

Also .. would simply updating their version of Perl to the newest version .. fix the problem?  Or, not?

The admins that work on this server are not knowledgable at all with Perl, or sendmail issues, etc.  So the more detail I can give them, the better.

Thanks,
Gary
0
 
kanduraCommented:
I'm not a sendmail expert, but it seems to require a system user named smmsp. My Fedora Core 3 came with sendmail, and has that user, so I guess adding it will solve the problem.
0
 
Gary GordonWebsite Developer, Designer, SEO and Online Marketing specialist.Author Commented:
Kandura,

So .. is sendmail part of the Perl installation?  Or what?  How does sendmail get onto the Linux server?  Is it put there by another installed application?  

And .. how would they go about adding this user?

I am not familiar with what My Fedora Core 3 is.

So you're saying they need to add a "system user" named smmsp.

Can you maybe just tell me how to add this user?

Thanks,
Gary
0
 
kanduraCommented:
Sendmail is the good old mail server program. It's been around for a very long time. On some operating systems, it's the default and comes preinstalled.

Fedore Core is Red Hats free version of linux.

Adding a user could be as simple as:

    adduser smmsp

0
 
ahoffmannCommented:
sendmail and perl are totally diffrent things
sendmail is not easy to configure, and more worse it's not easy to give a simple installation and/or configuration instruction 'cause there are some different versions in the wild and some linux also try to build their own one ...
Your server admin should be able to configuzre sendmail propper, or use another MTA and tell you how to use it.
0
 
Gary GordonWebsite Developer, Designer, SEO and Online Marketing specialist.Author Commented:
I appreciate all the help.

So, I can put this to rest (hahaha) ...I am thinking .. if someone can tell me (by maybe just revising my original script) .. how to use SMTP instead of SENDMAIL to handle this process, that might be the easiest way.

Is it possible to revise my script .. so it can use  mail.domainname.com  (as the SMTP) to send the email that way instead?  If so, please re-do my script to incorporate that functionality and I'll be done.  

I seriiously appreciate all the help.

Again, here is my original script:

=====================

#!/usr/bin/perl

$mailprog = '/usr/lib/sendmail';

$recipient = 'ggordon@garymgordon.com';

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
    {
    ($name, $value) = split(/=/, $pair);
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $FORM{$name} = $value;
    }


open (MAIL, "|$mailprog $recipient");
print MAIL "To: $recipient\n";
print MAIL "From: $FORM{'Email_Address'}\n";
print MAIL "Subject: Bishop Kelley Online Form\n\n";

foreach $pair(@pairs)
{
    ($name,$value)=split(/=/,$pair);
    $value=~ tr/+/ /;
    $name=~ tr/+/ /;
    $value=~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
    $name=~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
    $FORM{$name}=$value;
print MAIL "$name:\t $value\n\n";
}

close(MAIL);

print "Location: http://bkelleyhs.org/dvlp_cc_thnkupage.htm\n\n";

======================

Thanks,
Gary
0
 
TintinCommented:
While you can use the Net::SMTP module, I think it is easier/better to use a higher level module like MIME::Lite.  Here's a rewritten version of your script using MIME::Lite

#!/usr/bin/perl
use strict;
use CGI::Carp qw(fatalsToBrowser);
use CGI;
use MIME::Lite;

my $recipient = 'ggordon@garymgordon.com';

my $q = new CGI;
my %p = $q->Vars;
my $data;

foreach my $key (keys %p) {
  $data .= "$key $p{$key}\n";
}

my $msg = MIME::Lite->new(
        To      => $recipient,
        From    => $p{'Email_Address'},
        Subject => 'Bishop Kelly Online Form',
        Type    => 'TEXT',
        Data    => $data
);

MIME::Lite->send('smtp','your.smtp.server') or die "Can not send email $!\n";

print $q->redirect('http://bkelleyhs.org/dvlp_cc_thnkupage.htm');
0
 
Gary GordonWebsite Developer, Designer, SEO and Online Marketing specialist.Author Commented:
Hi. And, thanks.

I am not sure why .. because I looked on the server and it says that the MIME::Lite module is installed.

But I am getting this error message:

Software error:
Can't locate MIME/Lite.pm in @INC (@INC contains: /usr/lib/perl5/5.8.3/i386-linux-thread-multi /usr/lib/perl5/5.8.3 /usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2 /usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.2/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.1/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.3 /usr/lib/perl5/vendor_perl/5.8.2 /usr/lib/perl5/vendor_perl/5.8.1 /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl .) at bishopkelley_email_smtp.cgi line 5.
BEGIN failed--compilation aborted at bishopkelley_email_smtp.cgi line 5.


I was hoping you might be able to tell me where the problem might be?

Thanks,
Gary


0
 
ahoffmannCommented:
sounds like there is no proper MTA configured on your server, and MIME::Lite relies on on one by default ...

> so it can use  mail.domainname.com  (as the SMTP) to send the email that way instead?
something like following should always work for simple mails:

$to = 'user@some.where';
$sb = 'test mail via perl using telnet';
$body   = "\nfirst line must be empty after mail header\n\nThen any text\n";
open(MAIL, "|/usr/bin/telnet mx.some.where 25")
                               or die "Can't fork for mail: $!\n";
$mail = "HELO me\@here.tld"
      . "MAIL FROM: Me"
      . "RCPT TO: $to"
      . "DATA"
      . "Subject: $sb"
      . "$body"
      . "."
      . "QUIT";
print MAIL $mail ;
close(MAIL);
0
 
kanduraCommented:
#!/usr/bin/perl
use strict;
use CGI::Carp qw(fatalsToBrowser);
use CGI;
use Net::SMTP;

my $recipient = 'ggordon@garymgordon.com';

my $q = new CGI;
my %p = $q->Vars;
my $data;

foreach my $key (keys %p) {
  $data .= "$key $p{$key}\n";
}

my $smtp = Net::SMTP->new('your.smtp.server') or die "Can not send email $!\n";
$smtp->mail($p{'Email_Address'});
$smtp->to($recipient);
$smtp->data(
qq{Subject: Bishop Kelly Online Form    
From: $p{'Email_address'}
To: $recipient

$data
});
$smtp->quit;

print $q->redirect('http://bkelleyhs.org/dvlp_cc_thnkupage.htm');
0
 
TintinCommented:
Looks like as well as having a broken sendmail installation, your ISP also has a broken (or at least wierd) Perl installation.  I notice the INC path references three Perl versions.

It's very hard to get scripts working, when the things it relies on are broken.
0
 
kanduraCommented:
Tintin,
> I notice the INC path references three Perl versions.

You should see the @INC on a stock Fedora Core 3:

  @INC:
    /usr/lib/perl5/5.8.5/i386-linux-thread-multi
    /usr/lib/perl5/5.8.5
    /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.4/i386-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.5
    /usr/lib/perl5/site_perl/5.8.4
    /usr/lib/perl5/site_perl/5.8.3
    /usr/lib/perl5/site_perl/5.8.2
    /usr/lib/perl5/site_perl/5.8.1
    /usr/lib/perl5/site_perl/5.8.0
    /usr/lib/perl5/site_perl
    /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.8.4/i386-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.8.2/i386-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.8.1/i386-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.8.5
    /usr/lib/perl5/vendor_perl/5.8.4
    /usr/lib/perl5/vendor_perl/5.8.3
    /usr/lib/perl5/vendor_perl/5.8.2
    /usr/lib/perl5/vendor_perl/5.8.1
    /usr/lib/perl5/vendor_perl/5.8.0
    /usr/lib/perl5/vendor_perl

I could just cry when I see that. I fought hard to get Debian on those machines, but lost :(
0
 
Gary GordonWebsite Developer, Designer, SEO and Online Marketing specialist.Author Commented:
kandura,

I used your script ...

================

#!/usr/bin/perl
use strict;
use CGI::Carp qw(fatalsToBrowser);
use CGI;
use Net::SMTP;

my $recipient = 'ggordon@garymgordon.com';

my $q = new CGI;
my %p = $q->Vars;
my $data;

foreach my $key (keys %p) {
  $data .= "$key $p{$key}\n";
}

my $smtp = Net::SMTP->new('your.smtp.server') or die "Can not send email $!\n";
$smtp->mail($p{'Email_Address'});
$smtp->to($recipient);
$smtp->data(
qq{Subject: Bishop Kelly Online Form    
From: $p{'Email_address'}
To: $recipient

$data
});
$smtp->quit;

print $q->redirect('http://bkelleyhs.org/dvlp_cc_thnkupage.htm');

==============

And .. .it seems to run fine, but I am not receiving the emails.

(I did when I used sendmail, but not with the SMTP)

Do you think I need to include a username and password to get access to actually run the SMTP?  Just not sure.

I'm not getting any error.

I just don't know what's happening and why.

Any idea?

Gary
0
 
kanduraCommented:
garymgordon,
> Do you think I need to include a username and password to get access to
> actually run the SMTP?  Just not sure.

Maybe, you know better than I. You can try it by adding this line:

    $smtp->auth($login, $password);

Put it right after the new() call.
0
 
kanduraCommented:
alternatively, turn debugging on:

    my $smtp = Net::SMTP->new('your.smtp.server', Debug=>1) or die "Can not send email $!\n";

and run the script from the command line. let us know what that tells you.
0
 
Gary GordonWebsite Developer, Designer, SEO and Online Marketing specialist.Author Commented:
Is there a way to do this debugging without running the script from the command line?

I am running this on a shared server.  So, I don't have access to the command line.

???

Gary
0
 
ahoffmannCommented:
Net::SMTP, MIME::Lite, Mail::Mailer, etc. all rely on a installed and configured and running MTA (except you define your own one on initialization)
Use plain old telnet, see http:#13829759
0
 
Gary GordonWebsite Developer, Designer, SEO and Online Marketing specialist.Author Commented:
kandura,

Question ...

RE:

===================

garymgordon,
> Do you think I need to include a username and password to get access to
> actually run the SMTP?  Just not sure.

Maybe, you know better than I. You can try it by adding this line:

    $smtp->auth($login, $password);

Put it right after the new() call.

=======================

I am confused as to exactly where the  "  new () call " is.  hahaha   Can you show me exactly what you mean and where???

And, .. how do I set the $login and $password .. so that it will work appropriately.

Can you just explain this ... then I can try it and ... finish this up and award you the points.

Thanks,
Gary


0
 
Gary GordonWebsite Developer, Designer, SEO and Online Marketing specialist.Author Commented:
Kandura?

Help??
Gary
0
 
Gary GordonWebsite Developer, Designer, SEO and Online Marketing specialist.Author Commented:
Kandura,

I tried ....

=================

#!/usr/bin/perl
use strict;
use CGI::Carp qw(fatalsToBrowser);
use CGI;
use Net::SMTP;

my $recipient = 'ggordon@garymgordon.com';

my $q = new CGI;
my %p = $q->Vars;
my $data;
my $login = ('myusername');
my $password = ('mypassword');


foreach my $key (keys %p) {
  $data .= "$key $p{$key}\n";
}

my $smtp = Net::SMTP->new('mail.garymgordon.com') or die "Can not send email $!\n";
$smtp->auth($login,$password);
$smtp->mail($p{'Email_Address'});
$smtp->recipient($recipient);
$smtp->data(
qq{Subject: Bishop Kelly Online Form    
From: $p{'Email_Address'}
To: $recipient
$data
});
$smtp->quit;

print $q->redirect('http://bkelleyhs.org/dvlp_cc_thnkupage.htm');

=================


But I still don't receive the emails.  :(

Any ideas?

Gary


0
 
ahoffmannCommented:
can you check the mail logfile, on recipient side
0
 
Gary GordonWebsite Developer, Designer, SEO and Online Marketing specialist.Author Commented:
I am on a shared server.  So, I really can't look at the mail log files.

I am trying to figure out (if the script above is correct) ... what would be preventing me from receiving the emails.  I am set up to receive the emails.  

I'm not sure, but I am only guessing that the authorization may not be getting approved to send the emails through the SMTP.

Any idea how I can correct this so it will work?

Thanks,
Gary
0
 
Gary GordonWebsite Developer, Designer, SEO and Online Marketing specialist.Author Commented:
Kandura,

REPEAT OF MY LAST POST:

I am on a shared server.  So, I really can't look at the mail log files.

I am trying to figure out (if the script above is correct) ... what would be preventing me from receiving the emails.  I am set up to receive the emails.  

I'm not sure, but I am only guessing that the authorization may not be getting approved to send the emails through the SMTP.

Any idea how I can correct this so it will work?

Thanks,
Gary
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 16
  • 10
  • 8
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now