Hi all,

I'm writing my first CGI script and am baffled why it isn't working. 
It's a really basic cgi that has the user input form data in a couple
places, and these variables are used as arguments for another script
that I call after processing the form.  The script creates another file,
and works fine from the command line. 

The problem is that the CGI is not running the chansonreporter.pl
script, and I'm not getting any error messages.  Everything else works. 
Can someone please offer some insight?

Thanks, and please cc this address on all responses.

The code follows below.

Cheers,

James


#!/usr/local/bin/perl -w

# $Header: simple cgi form used to run script with form data as
arguments
#
# -jwilliam, 10/22/2001

require "cgi-lib.pl";

$dir = '/local/agfa2k';

$formail = "/usr/local/bin/formail -I 'X-Authentication-Warning:
automated email' -I 'Subject: AGFA MONTHLY REPORT' -I 'To:
jwilliam\@banta-im.com'";

$sendmail = '/usr/lib/sendmail -t -f "[EMAIL PROTECTED]"';



 MAIN: 
{
# Read in all the variables set by the form
  if (&ReadParse(*input)) {
    &ProcessForm;
  } else {
    &PrintForm;
  }
}

sub ProcessForm {

  # Print the header
  print &PrintHeader;
  print &HtmlTop ("AGFA MONTHLY REPORT");

  # Do some processing, and print some output
#  ($text = $input{'text'}) =~ s/\n/\n<BR>/g; 
                                   # add <BR>'s after carriage returns
                                   # to multline input, since HTML does
not
                                   # preserve line breaks
  print <<ENDOFTEXT;

  A report for $input{'mm'}/$input{'yy'} has been emailed.
ENDOFTEXT

  #  Close the document cleanly.
  print &HtmlBot;


  # run chansonreporter.pl script with form data as arguments, 
  # then email the report

##################################################
#   THIS IS THE SCRIPT THAT IS NOT BEING CALLED  #
##################################################

  `$dir/htdocs/chansonreporter.pl $input{'mm'} $input{'yy'}`;

  $report = "$dir/usagereports/agfa$input{'yy'}$input{'mm'}" . '.txt';
  `cat $report | $formail | $sendmail`;

}


sub PrintForm {

  print &PrintHeader;
  print &HtmlTop ("AGFA MONTHLY REPORT");


  # Print out the body of the form from a single quoted here-document
  # Note that if ENDOFTEXT weren't surrounded by single quotes,
  # it would be necessary to be more careful with the other text
  # For example, the @ sign (in the address) would need to be escaped as
\@
  print <<'ENDOFTEXT';

Welcome to the AGFA monthly reporting interface.
<BR>
A report will be mailed to [EMAIL PROTECTED] upon pressing submit.
</P>
<HR>
<form method="post" action="agfareport.cgi">
Enter the month in the form MM:    <input type ="text" name="mm" size=2
maxlength=2>
<P>
Enter the year in the form YY:    <input type ="text" name="yy" size=2
maxlength=2>
<P>
<P>

Press <input type="submit" value="submit"> to email the report.
</form>
<hr>
ENDOFTEXT

  print &HtmlBot;

}
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to