CGI error (need help)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bernard

    CGI error (need help)

    Hi,

    I have a problem with a CGI script (Perl) on a Win2000 server.
    The script is for sending E-cards and was written by Jason Maloney:

    You can choose from some cards, add your own text and send it to a friend.
    This friend get a mail which tell him/her that he/she has a mail and have to
    click a link.
    So far everything works just fine.
    But when the recipient clicks the link he/she gets the following error
    message in the browser window:
    ----------------------------------------------------
    CGI Error
    The specified CGI application misbehaved by not returning a complete set of
    HTTP headers. The headers it did return are:
    Can't open perl script
    "D:\Inetpub\HCO \www\cgi-bin\postcard\ca rd.cgi107002204 5": No such file or
    directory
    --------------------------------------------------------
    The cgi script is in \cgi-bin\postcard\ca rd.cgi
    But the data it has to retrieve is in
    \cgi-bin\postcard\ca rds\1070022045. dat(for example)
    Each mail generates a new .dat file.

    Any ideas???
    I already had contact with the author, but he tested it only on a Win NT
    server which worked just fine. He has no experience with Win2000 server

    You can try it on our test site:


    Thanks,
    Bernard


  • no_guru

    #2
    Re: CGI error (need help)

    On Fri, 28 Nov 2003 15:26:43 +0100, Bernard wrote:
    [color=blue]
    > Hi,
    >
    > I have a problem with a CGI script (Perl) on a Win2000 server.
    > The script is for sending E-cards and was written by Jason Maloney:
    > http://www.aestheticsurgerycenter.co...ostcard1.shtml
    > You can choose from some cards, add your own text and send it to a friend.
    > This friend get a mail which tell him/her that he/she has a mail and have to
    > click a link.
    > So far everything works just fine.
    > But when the recipient clicks the link he/she gets the following error
    > message in the browser window:
    > ----------------------------------------------------
    > CGI Error
    > The specified CGI application misbehaved by not returning a complete set of
    > HTTP headers. The headers it did return are:
    > Can't open perl script
    > "D:\Inetpub\HCO \www\cgi-bin\postcard\ca rd.cgi107002204 5": No such file or
    > directory
    > --------------------------------------------------------
    > The cgi script is in \cgi-bin\postcard\ca rd.cgi
    > But the data it has to retrieve is in
    > \cgi-bin\postcard\ca rds\1070022045. dat(for example)
    > Each mail generates a new .dat file.
    >
    > Any ideas???
    > I already had contact with the author, but he tested it only on a Win NT
    > server which worked just fine. He has no experience with Win2000 server
    >
    > You can try it on our test site:
    > http://195.86.135.223/cgi-bin/postcard/index.html
    >
    > Thanks,
    > Bernard[/color]

    Hey Bernard--

    I'm no guru, but I think I can help you with this one...

    when you're sending the e-mail to the recipient, the link that it
    generates (in this case,
    https://www.aestheticsurgerycenter.c....cgi1070022045) is
    missing a separator for the query string (the 1070022045 part). Find the
    portion of the script that puts the message together and add a
    question mark between the .cgi and the following varible, and it should work!

    hope that helps!

    no_guru






    Comment

    • Bernard

      #3
      Re: CGI error (need help)

      > Hey Bernard--[color=blue]
      >
      > I'm no guru, but I think I can help you with this one...
      >
      > when you're sending the e-mail to the recipient, the link that it
      > generates (in this case,
      > https://www.aestheticsurgerycenter.c....cgi1070022045) is
      > missing a separator for the query string (the 1070022045 part). Find the
      > portion of the script that puts the message together and add a
      > question mark between the .cgi and the following varible, and it should[/color]
      work![color=blue]
      >
      > hope that helps!
      >
      > no_guru[/color]
      Here's the code, I have no experience with Perl. So, maybe can you see which
      part of the script puts the message together.

      #!D:/Program Files/Perl/bin/perl.exe
      ############### ############### ############### ###########
      ############### ############### ############### ###########
      # Don't Edit This CGI Part #
      ############### ############### ############### ###########
      ############### ############### ############### ###########

      $i=0;
      read(STDIN,$buf fer,$ENV{'CONTE NT_LENGTH'});
      if ($ENV{'QUERY_ST RING'})
      {$buffer = "$buffer\&$ENV{ 'QUERY_STRING'} ";}
      @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;
      $VALUE{$name} = $value;
      }

      ############### ############### ##############
      #Gets the Current Date
      ############### ############### ##############
      ($sec,$min,$hr, $day,$month,$ye ar,$day_of_week ,$day_of_year,$ some) =
      localtime(time) ;
      @months =
      ("January","Feb ruary","March", "April","May"," June","July","A ugust","Septemb e
      r","October","N ovember","Decem ber");

      $year = $year + 1900;

      $DATE = "$months[$month]-$day";
      $SHORTDATE = "$months[$month] $day, $year at $hr:$min:$sec";

      ############### ############### ##############
      #Gets Picture Data and Moves on to Next Page
      ############### ############### ##############

      if ($VALUE{'action '} eq 'preview') {

      $pic = $VALUE{'PICTURE S'};
      $VALUE{'PICTURE '} = $VALUE{'PICTURE S'};
      $VALUE{'PICTURE S'} = "$basepicurl$pi c";

      print "Content-type: text/html\n\n";
      open(TEMPLATE," $preview1");
      &template;
      print $template;
      exit;
      }


      ############### ##########
      #Prints the Preview Page
      ############### ##########
      if ($VALUE{'action '} eq 'preview1') {
      $pic = $VALUE{'PICTURE '};
      $VALUE{'PICTURE S'} = "$basepicurl$pi c";

      $VALUE{'MESSAGE '} =~ s/\r//g;
      $VALUE{'MESSAGE '} =~ s/\<[^\>]*\>//ig;
      $VALUE{'MESSAGE '} =~ s/"/'/g;
      $VALUE{'MESSAGE '} =~ s/\n/<BR>/g;

      print "Content-type: text/html\n\n";
      open(TEMPLATE," $preview2");
      &template;
      print $template;
      exit;
      }

      ##########
      #Send Card
      ##########
      if ($VALUE{'action '} eq 'send') {
      &no_email unless $VALUE{'MAILFRO M'} && $VALUE{'MAILTO' };

      ############### #######
      #Save the Data
      ############### #######
      $date = time;
      $create_card = "$cards$date.da t";

      open(DATA, ">>$create_card ");
      print DATA
      "$VALUE{'SENDER '}|$VALUE{'MAIL FROM'}|$VALUE{' RECIPIENT'}|$VA LUE{'MAILTO'}|$ V
      ALUE{'MESSAGE'} |$VALUE{'PICTUR E'}|0\n";
      close(DATA);

      $url_of_card = "$cgi?$date ";

      ############### ###########
      #Print Thank You HTML
      ############### ###########
      print "Content-type: text/html\n\n";

      open(TEMPLATE," $thank_you");
      &template;
      print $template;

      $template = '';

      ############### ###########
      #Send E-mail to Recipient
      ############### ###########

      open (MAIL, "|$mailprog -t") || die "Kan $mailprog niet openen!\n";
      print MAIL "To: $VALUE{'MAILTO' } ($VALUE{'RECIPI ENT'})\n";
      print MAIL "From: $VALUE{'MAILFRO M'} ($VALUE{'SENDER '})\n";
      print MAIL "Subject: $VALUE{'RECIPIE NT'}, $subject1\n\n";

      open(TEMPLATE," $email1");
      &template;
      print MAIL $template;

      print MAIL ".\n" ;
      close(MAIL);

      $deletes = "$cards$DATE.da t";

      if(-e $deletes){
      }
      else{
      open(DATA, ">>$deletes ");
      close(DATA);
      &delete;
      }
      exit;
      }

      ############### #########
      #No E-Mail Addresses
      ############### #########
      sub no_email {
      print "Content-type: text/html\n\n";
      print "<HTML>\n<TITLE >Fout! E-Mail adres niet geldig</TITLE>\n";
      print "<BODY COLOR=\"#FFFFFF \">\n";
      print "Kan niet verstuurd worden!<BR>\n";
      print "<B>[Mogelijke oorzaken:]</B><BR>\n";
      print "&nbsp;&nbsp;1. ) U bent beide e-mail adressen vergeten in te
      vullen<BR>";
      print "&nbsp;&nbsp;2. ) E-Mail Adres(en) niet in de goed formaat ingetypt,
      <B>b.v. naam@bedrijf.co m</B>";
      exit;
      }

      ############### ############### #########
      #Creates the Postcard
      ############### ############### #########
      if ($ENV{'QUERY_ST RING'}) {

      ############### ############### ##############
      #Makes Postcards and Sends Thank You E-mail
      ############### ############### ##############
      $create_card = "$cards$ENV{'QU ERY_STRING'}.da t";

      if(-e $create_card){
      open(DATA, "$create_card") ;
      @data = <DATA>;
      close(DATA);

      foreach $temp (@data){
      chop($temp);
      ($SENDER, $MAILFROM, $RECIPIENT, $MAILTO, $MESSAGE, $PICTURES, $COUNT) =
      split(/\|/, $temp);

      $VALUE{'SENDER' } = $SENDER;
      $VALUE{'MAILFRO M'} = $MAILFROM;
      $VALUE{'RECIPIE NT'} = $RECIPIENT;
      $VALUE{'MAILTO' } = $MAILTO;
      $VALUE{'MESSAGE '} = $MESSAGE;
      $VALUE{'MESSAGE '} =~ s/ /&nbsp; /g;
      $VALUE{'PICTURE S'} = "$basepicurl$PI CTURES";
      $VALUE{'LINK'} = "$link$LINK ";
      $VALUE{'PICTURE '} = "$basepicurl$PI CTURES";
      }

      unlink("$create _card");

      open(DATA, ">>$create_card ");
      $COUNT++;
      print DATA
      "$SENDER|$MAILF ROM|$RECIPIENT| $MAILTO|$MESSAG E|$PICTURES|$CO UNT\n";
      close(DATA);

      print "Content-type: text/html\n\n";
      open(TEMPLATE," $makecard");
      &template;
      print $template;

      $template = '';

      if($COUNT eq '1'){
      open (MAIL, "|$mailprog -t") || die "Kan $mailprog niet openen!\n";
      print MAIL "To: $VALUE{'MAILFRO M'} ($VALUE{'SENDER '})\n";
      print MAIL "From: $VALUE{'MAILTO' } ($VALUE{'RECIPI ENT'})\n";
      print MAIL "Subject: $subject2\n\n";

      open(TEMPLATE," $email2");
      &template;
      print MAIL $template;

      print MAIL ".\n" ;
      close(MAIL);
      }
      }
      else {
      print "Content-type: text/html\n\n";
      open(TEMPLATE," $error");
      &template;
      print $template;
      }
      exit;
      }

      ############### ############### #########
      #DELETES the information
      ############### ############### #########
      sub delete {

      local(@items, $pair);
      opendir(DELETE, "$cards");
      @items = grep(/.dat/,readdir(DELETE ));
      closedir(DELETE );
      foreach $pair (@items){
      if (-M "$cards$pai r" > $MAX_DAYS){
      unlink("$cards$ pair");
      }
      }
      }

      ############### ######
      #Calls the Template
      ############### ######

      sub template {
      while (<TEMPLATE>){
      $template .= $_;
      }
      close(TEMPLATE) ;

      $template =~ s/\%%%PICTURES%%%/$VALUE{'PICTURE S'}/g;
      $template =~ s/\%%%PICTURE%%%/$VALUE{'PICTURE '}/g;
      $template =~ s/\%%%SENDER%%%/$VALUE{'SENDER' }/g;
      $template =~ s/\%%%MAILFROM%%%/$VALUE{'MAILFRO M'}/g;
      $template =~ s/\%%%MAILTO%%%/$VALUE{'MAILTO' }/g;
      $template =~ s/\%%%RECIPIENT%% %/$VALUE{'RECIPIE NT'}/g;
      $template =~ s/\%%%MESSAGE%%%/$VALUE{'MESSAGE '}/g;
      $template =~ s/\%%%CGI%%%/$cgi/g;
      $template =~ s/\%%%MAX_DAYS%%%/$MAX_DAYS/g;
      $template =~ s/\%%%SHORTDATE%% %/$SHORTDATE/g;
      $template =~ s/\%%%url_of_card %%%/$url_of_card/g;
      }


      Thx,
      Bernard


      Comment

      • Gunnar Hjalmarsson

        #4
        Re: CGI error (need help)

        Bernard wrote:[color=blue]
        > no_guru wrote:[color=green]
        >> Find the portion of the script that puts the message together and
        >> add a question mark between the .cgi and the following varible,
        >> and it should work![/color]
        >
        > Here's the code, I have no experience with Perl. So, maybe can you
        > see which part of the script puts the message together.[/color]

        Dear Bernard,

        It's very annoying to notice that you post the code here too, while
        ignoring the help I tried to give you in another group:



        On top of it, in this group you didn't post the part of the code that
        I suspect is causing the problem.

        What you are doing is called multi-posting, and it is very rude. Check
        the netiquette guidelines for Usenet.

        --
        Gunnar Hjalmarsson
        Email: http://www.gunnar.cc/cgi-bin/contact.pl

        Comment

        • Bernard

          #5
          Re: CGI error (need help)


          "Gunnar Hjalmarsson" <noreply@gunnar .cc> schreef in bericht
          news:mmeyb.3997 0$dP1.149963@ne wsc.telia.net.. .[color=blue]
          > Bernard wrote:[color=green]
          > > no_guru wrote:[color=darkred]
          > >> Find the portion of the script that puts the message together and
          > >> add a question mark between the .cgi and the following varible,
          > >> and it should work![/color]
          > >
          > > Here's the code, I have no experience with Perl. So, maybe can you
          > > see which part of the script puts the message together.[/color]
          >
          > Dear Bernard,
          >
          > It's very annoying to notice that you post the code here too, while
          > ignoring the help I tried to give you in another group:
          >
          >[/color]
          http://groups.google.com/groups?thre....uni-berlin.de[color=blue]
          >
          > On top of it, in this group you didn't post the part of the code that
          > I suspect is causing the problem.
          >
          > What you are doing is called multi-posting, and it is very rude. Check
          > the netiquette guidelines for Usenet.
          >
          > --
          > Gunnar Hjalmarsson
          > Email: http://www.gunnar.cc/cgi-bin/contact.pl
          >[/color]
          Dear Gunnar,

          I'm very sorry for this, but here at home my provider doesn't support this
          newsgroep. I thought I only could check it on monday on my work for your
          answers/effort.
          With the link you gave me now, I can read your answer and I wil try it right
          away.
          When something goes wrong, I try to get help where available. But it was not
          ment to overrule somebody.
          I was/am really please with your help.

          Bernard


          Comment

          • Gunnar Hjalmarsson

            #6
            Re: CGI error (need help)

            Bernard wrote:[color=blue]
            > Gunnar Hjalmarsson wrote:[color=green]
            >> What you are doing is called multi-posting, and it is very rude.
            >> Check the netiquette guidelines for Usenet.[/color]
            >
            > I'm very sorry for this,[/color]

            It's okay, now you know something about Usenet that you didn't know
            before. ;-)
            [color=blue]
            > but here at home my provider doesn't support this newsgroep.[/color]

            Do they support comp.lang.perl but not alt.perl? They'd better do it
            the other way around, because comp.lang.perl is actually defunct.

            --
            Gunnar Hjalmarsson
            Email: http://www.gunnar.cc/cgi-bin/contact.pl

            Comment

            Working...