Re: Perl cgi redirect not working

2003-10-05 Thread Nick Rogness
On Wed, 1 Oct 2003, Charles Howse wrote:

 Hi,

 I'm *copying an example* perl cgi script from FreeBSD Unleashed pp.
 699. I have 2 issues.

 1. The redirect on the last line isn't working.  It opens a blank page
 and prints the text Location: http://howse.no-ip.org/thanks.shtml;.
 That's not what I want.  I want to open the page thanks.shtml.

 2. I can't see the text in the book clear enough to know whether the
 characters I've marked with ^ should be dashes or tildies.

 I've Googled for the redirect, and tried a few examples, no joy. Would
 someone be kind enough to help?


 #!/usr/bin/perl

 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;
 ^
 $value =~ s/~!/ ~!/g;
 ^   ^   ^
 $FORM{$name} = $value;
 }

 print Content-type: text/html\n\n;

 open (MAIL,| /usr/sbin/sendmail -oi -t);
 print MAIL From: $FORM{'name'} $FORM{'email'}\n;
 print MAIL To: charles\n;
 print MAIL Subject: Contact form output\n\n;
 print MAIL $FORM{'name'}, from $ENV{'REMOTE_HOST'}
 ($ENV{'REMOTE_ADDR'}), has sent you the following comment:\n\n;
 print MAIL $FORM{'comment'}\n;
 close (MAIL);

 print Location: http://howse.no-ip.org/thanks.shtml\n\n;;


1) This is a little extreme for a simple redirect.  A simple 3 liner will
   do the trick:

  #!/usr/bin/perl

  print Location: http://howse.no-ip.org/thanks.shtml\n\n;;
  exit;


2) They are suppose to be tildes (~).

Nick Rogness [EMAIL PROTECTED]
-
  How many people here have telekenetic powers? Raise my hand.
-Emo Philips


___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


RE: Perl cgi redirect not working

2003-10-05 Thread Charles Howse
  #!/usr/bin/perl
 
  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;
  ^
  $value =~ s/~!/ ~!/g;
  ^   ^   ^
  $FORM{$name} = $value;
  }
 
  print Content-type: text/html\n\n;
 
  open (MAIL,| /usr/sbin/sendmail -oi -t);
  print MAIL From: $FORM{'name'} $FORM{'email'}\n;
  print MAIL To: charles\n;
  print MAIL Subject: Contact form output\n\n;
  print MAIL $FORM{'name'}, from $ENV{'REMOTE_HOST'}
  ($ENV{'REMOTE_ADDR'}), has sent you the following comment:\n\n;
  print MAIL $FORM{'comment'}\n;
  close (MAIL);
 
  print Location: http://howse.no-ip.org/thanks.shtml\n\n;;
 
 
 1) This is a little extreme for a simple redirect.  A simple 
 3 liner will
do the trick:
 
   #!/usr/bin/perl
 
   print Location: http://howse.no-ip.org/thanks.shtml\n\n;;
   exit;

Actually, this was a CGI script to respond to an email form on my
website.
When I posted asking the same question on a newsgroup, I was flamed so
severely for using buggy, crappy code that got busy, did some
research, and have moved 'up' to FormMail.pl, which is working perfectly
now.

The problem with the book code is that 'Content-type' line.
Removing it fixes that code.

 
 2) They are suppose to be tildes (~).

Thank you for a respectful answer.  :-)


___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


RE: Perl cgi redirect not working - Partially solved

2003-10-01 Thread Charles Howse
 Hi,
 I'm *copying an example* perl cgi script from FreeBSD Unleashed pp.
 699.
 I have 2 issues.
 
 1. The redirect on the last line isn't working.  It opens a blank page
 and prints the text Location: http://howse.no-ip.org/thanks.shtml;.
 That's not what I want.  I want to open the page thanks.shtml.
 
 2. I can't see the text in the book clear enough to know whether the
 characters I've marked with ^ should be dashes or tildies.
 
 I've Googled for the redirect, and tried a few examples, no joy.
 Would someone be kind enough to help?
 
 
 #!/usr/bin/perl
 
 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;
 ^
 $value =~ s/~!/ ~!/g;
 ^   ^   ^ 
 $FORM{$name} = $value;
 }
 
 print Content-type: text/html\n\n;
 
 open (MAIL,| /usr/sbin/sendmail -oi -t);
 print MAIL From: $FORM{'name'} $FORM{'email'}\n;
 print MAIL To: charles\n;
 print MAIL Subject: Contact form output\n\n;
 print MAIL $FORM{'name'}, from $ENV{'REMOTE_HOST'}
 ($ENV{'REMOTE_ADDR'}), has sent you the following comment:\n\n;
 print MAIL $FORM{'comment'}\n;
 close (MAIL);
 
 print Location: http://howse.no-ip.org/thanks.shtml\n\n;;

I removed the print Content-type: text/html\n\n; line, and now the
redirect works.
Still awaiting some input on the 2nd issue.


___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]