Gossamer Forum
Home : General : Perl Programming :

Why won't this work?

Quote Reply
Why won't this work?
Hi. I am trying to write an installation script for one of my scripts, but i am having trouble with it :) I have managed to write the script correctly except for showing the correct sub routine for the basic page, and then if they have submitted the form. As you can see i have had a go myself, but it didn't work very well! I just kept on getting the main sub-routine (sub start_page). Any ideas on how i can stop this happening would be much appreciated! To see what i mean please look at http://www.ace-installer.com/cgi-bin/install.cgi

Andy Cool

The script is below;

##############################################
# CODE
##############################################

#!/usr/bin/perl

if ($ENV{'REQUEST_METHOD'} eq 'GET') {
$buffer = $ENV{'QUERY_STRING'};
}
else {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
}

# Break em up into a format the script can read

@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;
$FORM{$name} = $value;
}

$action = $FORM{action};

if ($action ne "setup") { &start_page } else { &setup_script }

#########################################################
# FIRST SUB FOR START PAGE #
#########################################################

sub start_page
{
print "Content-type: text/html \n\n";
print qq|

<html>

<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Install Script for Ace Submit</title>
</head>

<body>

<form method="GET" action="install.cgi?action=setup">
<p>URL Site : <input type="text" name="urlsite" size="20"></p>
<p>Title :         <input type="text" name="title" size="20"></p>
<p>Port No:    <input type="text" name="portno" size="3" value="80">
<p>Date Location:    <input type="text" name="date" size="20" value="/bin/date">
<p>Database Location:    <input type="text" name="database" size="20" value="database.txt">
</p>
<p>Save E-Mails?  <select size="1" name="saveemailvalue">
<option value="1">Yes</option>
<option value="0">No</option>
</select></p>
<p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>

</body>

</html>

|;

}



###################################################
# SECOND SUB #
###################################################

sub setup_script
{

$home1 = "$FORM{urlsite}";
$org1 = "$FORM{title}";
$portno1 = "$FORM{portno}";
$saveemail = "$FORM{saveemailvalue}";
$date1 = "$FORM{date}";
$database1 = "$FORM{database}";

open(TOFILE,">settings.cfg");
flock(TOFILE,2);

print TOFILE "\#URL Path to your site \n";
print TOFILE "\$home = \"$home1\";\n";
print TOFILE "\n";
print TOFILE "\# Change to your Site Name\n";
print TOFILE "\$org = \"$org1\"\;\n";
print TOFILE "\n";
print TOFILE "\n";
print TOFILE "\$port = \"$portno1\"; \n";
print TOFILE "\n";
print TOFILE "\$saveemails = \"$saveemail\"\; \# 1 is yes, 0 is no \n";
print TOFILE "\n";
print TOFILE "\$date = \`$date1\`\; chop (\$date)\;\n";
print TOFILE "\n";
print TOFILE "\$database = \"$database1\"\;\n";


close(TOFILE);

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

print qq|

<html>

<head>
<title>Setup Done</title>
</head>

<body>

<p align="center">settings.cfg File has been generated. Now use the demo code made available in the zip file and change the location of the script in the HTML coding (http://www.ace-installer.com/cgi-bin/acesubmit.html). Don't change the values of the form boxes otherwise it won't work!"</a></p>

</body>

</html>

|;


}


##################################################
# END OF CODE
##################################################

Subject Author Views Date
Thread Why won't this work? Andy 4104 Dec 28, 2000, 3:38 AM
Thread Re: Why won't this work?
Paul 3973 Dec 29, 2000, 11:46 AM
Post Re: Why won't this work?
Andy 3954 Dec 29, 2000, 11:46 PM
Thread Re: Why won't this work?
jsu 3938 Dec 30, 2000, 12:34 AM
Thread Re: Why won't this work?
Andy 3919 Dec 31, 2000, 1:08 AM
Post Re: Why won't this work?
jsu 3908 Dec 31, 2000, 6:20 PM