linex,
First, you really should verify that this program compiles before attempting to run it. I know you have said that you don't have perl installed locally but it is freely available on almost every platform. See TinyPerl if you want to run it from a floppy disk or other external media.

Second, I find it hard to believe you can delete files on this host but that you can't create any. On most systems, your home directory or the /tmp directory is writeable by you. If you truly can't create any files anywhere then your script is never going to work because your own code is creating a file.

Third, CGI::Carp can't display compile time errors to the browser without a little help. For that you would need to bypass the web server log. See this for details. It assumes that you really can create a file.

Fourth, you should still be able to validate that the script compiles even if you don't have perl locally or a shell account on the host. Create a new script that executes a system call to perl -wc of the first script. Since you are unlinking files and opening pipes to external mail programs - I don't see why this wouldn't work.

I do hope that you can get things to work. If none of these other pieces of information are helpful then try a completely different approach. Start out with a working script that doesn't nothing more than prints "hello, world" to the browser screen. Next add on a single bit of information and test it. Continue this process until you find exactly what the problem is or you get a working solution.

Update:
I have taken the liberty of re-writing your code to something I know compiles and corrects some of the logic problems of your own. I say some because you have a race condition that you will have to address on your own if it is a real issue. Use this at your own risk as it comes with no guarantees.

#!/usr/bin/perl use strict; use warnings; use CGI qw/:standard/; use CGI::Carp qw(fatalsToBrowser); my $prog = '/usr/lib/sendmail'; my $to = 'Foo@nowhere.com'; my $from = 'Bar@somewhere.com'; my $file = 'report.txt'; my $num = 0; if ($ENV{QUERY_STRING} eq 'new' && -e $file) { unlink $file or die "Unable to remove '$file': $!"; } else { open(my $fh, '<', $file) or die "Unable to open '$file' for readin +g: $!"; $num = <$fh>; chomp $num; } my ($col, $n) = (2, 0); for my $i (1 .. $col) { $n = $i + $num; open (my $mail, '|-', $prog) or die "Unable to open a pipe to '$pr +og': $!"; gen_message($mail, $to, $from); } open(my $fh, '<', $file) or die "Unable to open '$file' for writing: $ +!"; print $fh $num + $col; close $fh; print header, start_html($num), $num, end_html(); sub gen_message { my ($mail, $to, $from) = @_; print $mail "Content-Type: text/plain; charset = windows - 1251\n" +; print $mail "Subject: Text, Text!\n"; print $mail "To: $to\n"; print $mail "From: $from\n\n"; print $mail "Hello, the message text itself..\n"; print $mail "\n\n"; }

Cheers - L~R


In reply to Re: I'm getting a 500 Internal Server Error - how can I make this work? by Limbic~Region
in thread I'm getting a 500 Internal Server Error - how can I make this work? by linex

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.