Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

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

Status
Not open for further replies.

ggordon

Programmer
Sep 15, 2003
45
Weird problem (for me).

Here's the script I am running.

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

#!/usr/bin/perl

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

$recipient = 'test@test1.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:
============================

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
 
check the first line is correct on the server where the script does not work:

#!/usr/bin/perl

that is the most common shebang line but some servers use a different path. Make sure the path to sendmail is the same on both servers too. Are both servers Linux/Unix?
 
Kevin,

Yes ... /usr/bin/perl exists and is correct.

Any other thoughts.

Thanks,
Gary


Gary M. Gordon
 
location of sendmail??
Code:
open (MAIL, "/usr/lib/sendmail") or dir "roaring $!";


HTH
--Paul

cigless ...
 
Paul,

I recently checked and send mail is at /usr/sbin/sendmail

So, I changed this, but I still get the same error message.

I wasn't sure what to do with the code you provided:

open (MAIL, "/usr/lib/sendmail") or dir "roaring $!";

Did you want me to insert this, and if so, exactly where and how?

Thanks,
Gary

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



Gary M. Gordon
 
Try running the script on the command line, and that'll tell where the script is breaking.

Code:
%perl script.pl

If you change this line
Code:
$mailprog = '/usr/lib/sendmail';
to
Code:
$mailprog = '/usr/sbin/sendmail';

it could/should sort it out

the die statement should have indicated that the script couldn't open the mail program at the location specified
HTH
--Paul

cigless ...
 
Code:
or dir "roaring
should have read
Code:
or die "roaring

Oops, my bad, too late going to bed now

--paul

cigless ...
 
I had two other "thoughts" in my original post:

Make sure the path to sendmail is the same on both servers too. Are both servers Linux/Unix?
 
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
 
are you using the pipe "|" in the open command?

open (MAIL, "|$mailprog $recipient");

I see the line Paul posted is missing it, not sure if that would be the cause of the problem though if it were missing.
 
yes, I am using the pipe in the open command.

but the problem appears to be with sendmail's configuration or something.

I am, at this point, trying to fugure out issues regarding sendmail's configuration issue ....

What steps should they take to test sendmail's configuration?

How can they tell what it is about sendmail that isn't configured properly?

I am guessing that I will need to tell the system admins "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.

Any thoughts on my above questions????

Thanks,
Gary
 
Look into Net::SMTP for sending mails

I hate sendmail because of this sort of stuff

CPAN

--Paul

cigless ...
 
Paul,

On Linux/Unix, what other option is there to SEND email from within a script? Is there another application that you'd recommend? Just let me know what it is, how to get it, etc., etc.

Is SENDMAIL part of the Perl installation? If so, will it help to re-install and update the version of Perl on the server?

Gary


Gary M. Gordon
ggordon@garymgordon.com
 
the program sendmail is not part of perl. I am pretty sure that NET::SMTP is one of the core perl modules so it's probably already installed with perl. You can read the documents online at perldoc or cpan. If you must have sendmail installed and running properly then checkout the sendmail website:
 
If I want to use SMTP rather than Sendmail, .. how would I modify my code to do this?

Is it easy or hard? I don't know how to accomplish this, and based upon what I am seeing .. it might be a good alternative.

:)

The current code (using sendmail) is:


#!/usr/bin/perl

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

$recipient = 'test@test1.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:


If someone can modify this so it would use SMTP .. that would be great. The SMTP is mail.bkelleyhs.org

Thanks,
Gary
 
Gary,

have you changed the $mailprog variable yet, doesn't look like it

Net::SMTP is very easy to use have a look at the documentation

--Paul
 
Paul,

I didn't change anything really.

I apologize, but I don't know what to change. I looked at the documentation, but was confused. Again, I apologize for my lack of knowledge on this.

If you can show me exactly what needs to be changed, that would be great.

Gary
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top