From owner-freebsd-questions@FreeBSD.ORG Sun Oct 5 01:52:01 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 17A8D16A4B3 for ; Sun, 5 Oct 2003 01:52:01 -0700 (PDT) Received: from skywalker.rogness.net (skywalker.rogness.net [64.251.173.102]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2E5C443FCB for ; Sun, 5 Oct 2003 01:52:00 -0700 (PDT) (envelope-from nick@rogness.net) Received: from skywalker.rogness.net (localhost [127.0.0.1]) by skywalker.rogness.net (8.12.5/8.12.5) with ESMTP id h958vaVs045464; Sun, 5 Oct 2003 02:57:37 -0600 (MDT) (envelope-from nick@rogness.net) Received: from localhost (nick@localhost)h958vZNa045461; Sun, 5 Oct 2003 02:57:36 -0600 (MDT) X-Authentication-Warning: skywalker.rogness.net: nick owned process doing -bs Date: Sun, 5 Oct 2003 02:57:33 -0600 (MDT) From: Nick Rogness To: Charles Howse In-Reply-To: <005901c3883e$12780030$04fea8c0@moe> Message-ID: <20031005025435.U45148-100000@skywalker.rogness.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-questions@freebsd.org Subject: Re: Perl cgi redirect not working X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Oct 2003 08:52:01 -0000 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 - How many people here have telekenetic powers? Raise my hand. -Emo Philips