Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Post ing information to the perl

Status
Not open for further replies.

Guest_imported

New member
Joined
Jan 1, 1970
Messages
0
Why the heck won't my .pl accept incoming posts from itself... I put a form in there... with hidden values only.. try posting it with all of the inputs redirected properly... and the HTML page doesn't change a bit... same with Get for that matter.. mods 777 ... so what is wrong???
Thanks
Gareth
 
Need a little more detail/context. Can you post the code you are trying?




keep the rudder amid ship and beware the odd typo
 
#!/usr/bin/perl
##########################################################################################
# Dash.pl is used for displaying passed variables more asthetically on a dashboard (car)##
# 25/06/2001 Gareth Kirwan, Thermeon Europe Ltd ##########################################
##########################################################################################
# Incoming variables are: ###
# ###################################################################################### #
# user= : This is the User (company) currently logged in and must be used more for our ###
# purposes than the customers. It is used on the get/post requests to Robert's ###
# scripts that quiz the carsplus database for the list of locations and the car###
# clases. It is also displayed on the dash for the user's amusement (!) ###
# ###################################################################################### #
# fleet= : The size of the fleet in total or the fleet at the location... or the class ###
# code fleet at the location... depending on which options have been chosen. ###
# ###################################################################################### #
# rent= : The number of vehicles on rent in the fleet ... or at the location ... or in ###
# a certain class (you get the idea!) ###
# ###################################################################################### #
# unavail= : The number of vehicles which are unvailable in the fleet ... location ... ###
# or in a class (right.... from now this is refered to as FLC... ok) #### ###################################################################################### #
# clocation= : The current location for which the FLC is being displayed. ###
# ###################################################################################### #
# cclass= : The current class for which the FLC is being displayed.
# ###################################################################################### #
# cdate= : The current date for which the FLC information is being displayed. This can ###
# either be now or month to date. ###
##########################################################################################

# Sub calling
##########################################################################################

# Get the Input and read it
&GetInput;
# end

# Set variables
&SetVars;
# end

# set the number of zeros to be used in the odometers and also to be called for
# calibrating the three (technically) needles on the dials
&Zerox;

##########################################################################################
# HTML is what follows mainly... although a little messy in places.

print "Content-type: text/html \n\n";
print &quot;<html>&quot;;
print &quot;<head>&quot;;
print &quot;<title>Performance of $user</title>&quot;;
print &quot;<meta http-equiv=\&quot;Content-Type\&quot; content=\&quot;text/html; charset=iso-8859-1\&quot;>&quot;;
if ($incr >= 5){
$diver = &quot;1$addtoinc&quot;;
$muller = 270 / $diver;
}
elsif ($incr < 5 || (!$incr)){
$diver = &quot;1$addtoinc&quot;;
$muller = 540 / $diver;
}
print &quot;<SCRIPT language=javascript>\n
function both() {
if ($util > 120){
total = 225;
Rev.rotate(0,0,total);
}
else {
multiple = $util * 2.25;
total = multiple - 45;
Rev.rotate(0,0,total);
}

multipleb = $rent * $muller;
totalb = multipleb - 45;
Speed.rotate(0,0,totalb);

multiplec = $infleet * $muller;
totalc = multiplec - 45;
fleetsize.rotate(0,0,totalc);
}
</SCRIPT>&quot;;
print &quot;</head>&quot;;
print &quot;<body bgcolor=\&quot;#FFFFFF\&quot; text=\&quot;#000000\&quot; onload=both(); topmargin=\&quot;0\&quot; leftmargin=\&quot;0\&quot;>&quot;;
print &quot;<div id=\&quot;Util\&quot; style=\&quot;position:absolute; left:13px; top:31px; width:266px; height:134px; z-index:1\&quot;>&quot;;
print &quot;<object id=\&quot;Rev\&quot; classid=\&quot;CLSID:369303C2-D7AC-11D0-89D5-00A0C90833E6\&quot; style=\&quot;position:absolute;top:33px;left:309px;width:200px;height:200px\&quot;>&quot;;
print &quot;<param name=\&quot;Line0001\&quot; value=\&quot;setlinecolor(255,0,0)\&quot;>&quot;;
print &quot;<param name=\&quot;Line0002\&quot; value=\&quot;setfillcolor(255,0,0)\&quot;>&quot;;
print &quot;<param name=\&quot;Line0003\&quot; value=\&quot;Polygon(5, 0, 2, -85, 1, -85, -1, 0, -2, 0, 0)\&quot;>&quot;;
print &quot;</object></div>&quot;;
if ($zchars){
if ($zchars < 4){
print &quot;<div id=\&quot;zerox\&quot; style=\&quot;position:absolute; left:145px; top:185px; width:50=px; height:16px; z-index:1\&quot;>&quot;;
print &quot;<font face=\&quot;palatino linotype\&quot; size=\&quot;2\&quot; color=\&quot;blue\&quot;><center><b>&quot;;
print &quot;1$zeros&quot;;
print &quot;</b></center></font></div>&quot;;
}
else {
print &quot;<div id=\&quot;zerox\&quot; style=\&quot;position:absolute; left:145px; top:185px; width:50=px; height:16px; z-index:1\&quot;>&quot;;
print &quot;<font face=\&quot;palatino linotype\&quot; size=\&quot;2\&quot; color=\&quot;blue\&quot;><center><b>&quot;;
print &quot;10<sup>$zchars</sup>&quot;;
print &quot;</b></center></font></div>&quot;;
}
}
else {
print &quot;<div id=\&quot;zerox\&quot; style=\&quot;position:absolute; left:130px; top:190px; width:25=px; height:25px; z-index:1\&quot;>&quot;;
print &quot;<img src=\&quot;../spacer.gif\&quot; width=\&quot;15\&quot; height=\&quot;10\&quot;>&quot;;
print &quot;</div>&quot;;
}
print &quot;<div id=\&quot;stamping\&quot; style=\&quot;position:absolute; left:401px; top:207px; width:52px; height:16px; z-index:2\&quot;>&quot;;
print &quot;<font color=\&quot;white\&quot; face=\&quot;arial\&quot; size=2><b>&quot;;
if ($uchars == &quot;0&quot; || ((!$unavail) && (!$unavail[0]))){
print &quot;0 0 0 0&quot;;
}
else {
if ($uchars == 1){
print &quot;0 0 0 @unavail&quot;;
}
if ($uchars == 2){
print &quot;0 0 $unavail[0] $unavail[1]&quot;;
}
if ($uchars > 4){
print &quot;9 9 9 9&quot;;
}
if ($uchars == 3){
print &quot;0 $unavail[0] $unavail[1] $unavail[2]&quot;;
}
if ($uchars == 4) {
print &quot;$unavail[0] $unavail[1] $unavail[2] $unavail[3]&quot;;
}
}
print &quot;<b></font><center>&quot;;
print &quot;</div>&quot;;
print &quot;<div id=\&quot;stamping\&quot; style=\&quot;position:absolute; left:126px; top:207px; width:52px; height:16px; z-index:3\&quot;>&quot;;
print &quot;<font color=\&quot;white\&quot; face=\&quot;arial\&quot; size=2><b>&quot;;
print &quot;<font color=\&quot;white\&quot; face=\&quot;arial\&quot; size=2><b>&quot;;
if ($fchars == &quot;0&quot; || ((!$fleet) && (!$fleet[0]))){
print &quot;0 0 0 0 0&quot;;
}
else {
if ($fchars == &quot;1&quot;){
print &quot;0 0 0 0 $fleet&quot;;
}
if ($fchars == &quot;2&quot;){
print &quot;0 0 0 $fleet[0] $fleet[1]&quot;;
}
if ($fchars == &quot;3&quot;){
print &quot;0 0 $fleet[0] $fleet[1] $fleet[2]&quot;;
}
if ($fchars == &quot;4&quot;){
print &quot;0 $fleet[0] $fleet[1] $fleet[2] $fleet[3]&quot;;
}
if ($fchars == &quot;5&quot;){
print &quot;$fleet[0] $fleet[1] $fleet[2] $fleet[3] $fleet[4]&quot;;
}
if ($fchars > 6){
print &quot;9 9 9 9 9&quot;;
}
}
print &quot;<b></font><center>&quot;;
print &quot;<b></font><center>&quot;;
print &quot;</div>&quot;;
print &quot;<div id=\&quot;Rent\&quot; style=\&quot;position:absolute; left:13px; top:31px; width:266px; height:134px; z-index:3\&quot;>&quot;;
print &quot;<object id=\&quot;fleetsize\&quot; classid=\&quot;CLSID:369303C2-D7AC-11D0-89D5-00A0C90833E6\&quot; style=\&quot;position:absolute;top:33px;left:39px;width:200px;height:200px\&quot;>&quot;;
print &quot;<param name=\&quot;Line0001\&quot; value=\&quot;setlinecolor(0,255,0)\&quot;>&quot;;
print &quot;<param name=\&quot;Line0002\&quot; value=\&quot;setfillcolor(0,255,0)\&quot;>&quot;;
print &quot;<param name=\&quot;Line0003\&quot; value=\&quot;Polygon(4, -70, 1, -88, 1, -88, -1, -70, -1)\&quot;>&quot;;
print &quot;</object></div><center>&quot;;
print &quot;<div id=\&quot;Rent\&quot; style=\&quot;position:absolute; left:13px; top:31px; width:266px; height:134px; z-index:4\&quot;>&quot;;
print &quot;<object id=\&quot;Speed\&quot; classid=\&quot;CLSID:369303C2-D7AC-11D0-89D5-00A0C90833E6\&quot; style=\&quot;position:absolute;top:33px;left:39px;width:200px;height:200px\&quot;>&quot;;
print &quot;<param name=\&quot;Line0001\&quot; value=\&quot;setlinecolor(255,0,0)\&quot;>&quot;;
print &quot;<param name=\&quot;Line0002\&quot; value=\&quot;setfillcolor(255,0,0)\&quot;>&quot;;
print &quot;<param name=\&quot;Line0003\&quot; value=\&quot;Polygon(5, 0, 2, -85, 1, -85, -1, 0, -2, 0, 0)\&quot;>&quot;;
print &quot;</object></div><center>&quot;;
print &quot;<div id=\&quot;Rent\&quot; style=\&quot;position:absolute; left:270px; top:225px; width:35px; height:35px; z-index:5\&quot;>&quot;;
# print &quot;<img src=\&quot;../refreshon.gif\&quot; name=\&quot;refresh\&quot; border=\&quot;0\&quot; onmouseover=document.refresh.src=\&quot;../refreshoff.gif\&quot; onmouseout=document.refresh.src=\&quot;../refreshon.gif\&quot; onclick=top.self.location=\&quot;dash.cgi?$in&clocation=$nlocation\&quot;>&quot;;
print &quot;<form method=\&quot;post\&quot; action=\&quot;dash.cgi\&quot;>&quot;;
print &quot;<input type=\&quot;hidden\&quot; name=\&quot;clocation\&quot; value=\&quot;here\&quot;>&quot;;
print &quot;<input type=image src=../refreshoff.gif>&quot;;
print &quot;</form>&quot;;
print &quot;</div>&quot;;
$temprent = $rentchars;
$overrent = $temprent--;
if ($overrent > 9) { $overrent = 9;}
if ($rentchars > 5){
$rentlcd = &quot;$rents[0]x10<sup><font size=4>$overrent</font></sup>&quot;;
}
else { $rentlcd = $rent;}
if ($rentchars == 5){
print &quot;<div id=\&quot;Rentlcd\&quot; style=\&quot;position:absolute; left:53px; top:267px; width:55px; height:20px; z-index:6\&quot;>&quot;;
print &quot;<font face=\&quot;arial\&quot; color=\&quot;black\&quot; size=5><b>&quot;;
print &quot;$rentlcd&quot;;
print &quot;</font></b></div>&quot;;
}
elsif ($rentchars > 5){
print &quot;<div id=\&quot;Rentlcd\&quot; style=\&quot;position:absolute; left:53px; top:266px; width:55px; height:20px; z-index:6\&quot;>&quot;;
print &quot;<font face=\&quot;arial\&quot; color=\&quot;black\&quot; size=5><b>&quot;;
print &quot;$rentlcd&quot;;
print &quot;</font></b></div>&quot;;
}
else {
print &quot;<div id=\&quot;Rentlcd\&quot; style=\&quot;position:absolute; left:59px; top:267px; width:55px; height:20px; z-index:6\&quot;>&quot;;
print &quot;<font face=\&quot;arial\&quot; color=\&quot;black\&quot; size=5><b>&quot;;
print &quot;$rentlcd&quot;;
print &quot;</font></b></div>&quot;;
}
print &quot;<div id=\&quot;utillcd\&quot; style=\&quot;position:absolute; left:466px; top:267px; width:55px; height:20px; z-index:6\&quot;>&quot;;
if ($util > 999){
print &quot;<font face=\&quot;arial\&quot; color=\&quot;black\&quot; size=5><b>&quot;;
print &quot;999\%&quot;;
print &quot;</font></b></div>&quot;;
}
else {
print &quot;<font face=\&quot;arial\&quot; color=\&quot;black\&quot; size=5><b>&quot;;
print &quot;$util\%&quot;;
print &quot;</font></b></div>&quot;;
}
${sinc} = &quot;0&quot;;
if ($incr < 5){
${ainc} = &quot;5&quot;;
${binc} = &quot;10&quot;;
${cinc} = &quot;15&quot;;
${dinc} = &quot;20&quot;;
${einc} = &quot;25&quot;;
${finc} = &quot;30&quot;;
${ginc} = &quot;35&quot;;
${hinc} = &quot;40&quot;;
${iinc} = &quot;45&quot;;
${jinc} = &quot;50&quot;;
}
if ($incr >= 5){
${ainc} = &quot;10&quot;;
${binc} = &quot;20&quot;;
${cinc} = &quot;30&quot;;
${dinc} = &quot;40&quot;;
${einc} = &quot;50&quot;;
${finc} = &quot;60&quot;;
${ginc} = &quot;70 &quot;;
${hinc} = &quot;80&quot;;
${iinc} = &quot;90&quot;;
${jinc} = &quot;100&quot;;
}
print &quot;<div id=\&quot;1inc\&quot; style=\&quot;position:absolute; left:84px; top:173px; width:20px; height:20px; z-index:7\&quot;>&quot;;
print &quot;<font face=\&quot;palatino linotype\&quot; color=\&quot;black\&quot; size=3><b>&quot;;
print &quot;${ainc}&quot;;
print &quot;</font></b></div>&quot;;
print &quot;<div id=\&quot;0inc\&quot; style=\&quot;position:absolute; left:95px; top:198px; width:20px; height:20px; z-index:7\&quot;>&quot;;
print &quot;<font face=\&quot;palatino linotype\&quot; color=\&quot;black\&quot; size=3><b>&quot;;
print &quot;${sinc}&quot;;
print &quot;</font></b></div>&quot;;
print &quot;<div id=\&quot;2inc\&quot; style=\&quot;position:absolute; left:83px; top:143px; width:20px; height:20px; z-index:7\&quot;>&quot;;
print &quot;<font face=\&quot;palatino linotype\&quot; color=\&quot;black\&quot; size=3><b>&quot;;
print &quot;${binc}&quot;;
print &quot;</font></b></div>&quot;;
print &quot;<div id=\&quot;3inc\&quot; style=\&quot;position:absolute; left:95px; top:115px; width:20px; height:20px; z-index:7\&quot;>&quot;;
print &quot;<font face=\&quot;palatino linotype\&quot; color=\&quot;black\&quot; size=3><b>&quot;;
print &quot;${cinc}&quot;;
print &quot;</font></b></div>&quot;;
print &quot;<div id=\&quot;4inc\&quot; style=\&quot;position:absolute; left:116px; top:98px; width:20px; height:20px; z-index:7\&quot;>&quot;;
print &quot;<font face=\&quot;palatino linotype\&quot; color=\&quot;black\&quot; size=3><b>&quot;;
print &quot;${dinc}&quot;;
print &quot;</font></b></div>&quot;;
print &quot;<div id=\&quot;5inc\&quot; style=\&quot;position:absolute; left:143px; top:87px; width:20px; height:20px; z-index:7\&quot;>&quot;;
print &quot;<font face=\&quot;palatino linotype\&quot; color=\&quot;black\&quot; size=3><b>&quot;;
print &quot;${einc}&quot;;
print &quot;</font></b></div>&quot;;
print &quot;<div id=\&quot;6inc\&quot; style=\&quot;position:absolute; left:169px; top:98px; width:20px; height:20px; z-index:7\&quot;>&quot;;
print &quot;<font face=\&quot;palatino linotype\&quot; color=\&quot;black\&quot; size=3><b>&quot;;
print &quot;${finc}&quot;;
print &quot;</font></b></div>&quot;;
print &quot;<div id=\&quot;7inc\&quot; style=\&quot;position:absolute; left:189px; top:115px; width:20px; height:20px; z-index:7\&quot;>&quot;;
print &quot;<font face=\&quot;palatino linotype\&quot; color=\&quot;black\&quot; size=3><b>&quot;;
print &quot;${ginc}&quot;;
print &quot;</font></b></div>&quot;;
print &quot;<div id=\&quot;8inc\&quot; style=\&quot;position:absolute; left:201px; top:142px; width:20px; height:20px; z-index:7\&quot;>&quot;;
print &quot;<font face=\&quot;palatino linotype\&quot; color=\&quot;black\&quot; size=3><b>&quot;;
print &quot;${hinc}&quot;;
print &quot;</font></b></div>&quot;;
print &quot;<div id=\&quot;9inc\&quot; style=\&quot;position:absolute; left:202px; top:172px; width:20px; height:20px; z-index:7\&quot;>&quot;;
print &quot;<font face=\&quot;palatino linotype\&quot; color=\&quot;black\&quot; size=3><b>&quot;;
print &quot;${iinc}&quot;;
print &quot;</font></b></div>&quot;;
print &quot;<div id=\&quot;10inc\&quot; style=\&quot;position:absolute; left:189px; top:197px; width:20px; height:20px; z-index:7\&quot;>&quot;;
print &quot;<font face=\&quot;palatino linotype\&quot; color=\&quot;black\&quot; size=3><b>&quot;;
print &quot;${jinc}&quot;;
print &quot;</font></b></div>&quot;;
print &quot;<div id=\&quot;10inc\&quot; style=\&quot;position:absolute; left:240px; top:25px; width:150px; height:45px; z-index:9\&quot; align=left>&quot;;
print &quot;<font face=\&quot;arial\&quot; color=\&quot;black\&quot; size=1><b>&quot;;
print &quot;Location: $clocation<br>&quot;;
print &quot;Class: $cclass<br>&quot;;
print &quot;Date: $cdate<br>&quot;;
use POSIX qw(strftime);
$time = strftime &quot;%H:%M:%S&quot;, localtime;
print &quot;Time: $time&quot;;
print &quot;</font></div>&quot;;
print &quot;<img src=\&quot;../background.gif\&quot; align=\&quot;center\&quot; border=\&quot;0\&quot;><br></body></html>&quot;;


##########################################################################################
# GetInput reads the incoming information and places it in associative arrays.
sub GetInput {
local (*in) = @_ if @_;
local ($i, $loc, $key, $val);
if ( $in_copy ) {
$in = $in_copy;
} elsif ($ENV{'REQUEST_METHOD'} eq &quot;GET&quot;) {
$in = $ENV{'QUERY_STRING'};
} elsif ($ENV{'REQUEST_METHOD'} eq &quot;POST&quot;) {
read(STDIN,$in,$ENV{'CONTENT_LENGTH'});
} elsif ($ENV{'REQUEST_METHOD'} eq &quot;STDIN&quot;) {
$in = '';
while ( read(STDIN,$buffer,1024) )
{
$in .= $buffer;
}
} else {
$in=$ARGV[0];
}
$in_copy = $in unless ($in_copy);
@in = split(/&/,$in);
foreach $i (0 .. $#in) {
# Convert plus's to spaces
$in[$i] =~ s/\+/ /g;

# Convert %XX from hex numbers to alphanumeric
$in[$i] =~ s/%(..)/pack(&quot;c&quot;,hex($1))/ge;

# Split into key and value.
($key, $val) = split(/=/,$in[$i],2); # splits on the first =.

$in{$key} = $val;
}
}
# end of GetInput
##########################################################################################

# Set vars associates more meaningful names with the incoming variables for the script
sub SetVars {
$clocation = $in{clocation};
$cclass = &quot;All&quot;;
$cdate = &quot;Today&quot;;
$user = $in{user};
$util = $in{util};
@utils = split(//, $util);
$utilchars = @utils.&quot;&quot;;
$rent = $in{rent};
@rents = split(//, $rent);
$rentchars = @rents.&quot;&quot;;
$infleet = $in{fleet};
@fleet = split(//, $infleet);
$fchars = @fleet.&quot;&quot;;
$inunavail = $in{unavail};
@unavail = split(//, $inunavail);
$uchars = @unavail.&quot;&quot;;
$chars = $fchars;
$incr = $fleet[0];
$nuchars = --$chars;
$multiple = --$nuchars;
}
# end of SetVars
##########################################################################################

# set the zeros for the odometers on divs stamping
sub Zerox {
if ($multiple == 0){$end = 1;}
until ($multiple == 0)
{
$i++;
$multiple--;
$zeros .= &quot;0&quot;;
}
$dialnu = ++$chars;
until ($dialnu == 0)
{
$i++;
$dialnu--;
$addtoinc .= &quot;0&quot;;
}

if (!$end){
if ($i == 1){$zchars = 1;}
else {
@numzero = split(//, $zeros);
$zchars = @numzero.&quot;&quot;}
}

}
# end
#############################################
 
I asked for it....8-)


keep the rudder amid ship and beware the odd typo
 
I'm not sure how you are using this code, but, in sub Zerox, when I play with this, it is possible to get a starting value for $multiple that is less than 0. Consequently, you decrement that variable infinitely until it reaches 0, which is never...... it goes further negative. It seems to be starting at -2.

The CGI variable parsing seems to work. I don't have time to check through all the javascript stuff, but, I am very suspicious of how you are feeding the Zerox sub.

I did this to test it.

I modified the code to 'die' after the call to Zerox and tried to print a few vars
before the 'die'.
Code:
#!/usr/bin/perl
# Get the Input and read it
&GetInput;

# Set variables 
&SetVars;

# set the number of zeros to be used in the odometers and also to be called for
# calibrating the three (technically) needles on the dials
&Zerox;

print &quot;USER = $user\n&quot;;
print &quot;Cdate = $cdate\n&quot;;
die; # I don't care to see the HTML in a terminal window

# of course, I  included the subs that are called, just did not paste them here

I modified sub Zerox like this, JUST TO SEE IF it would work once it hit zero.
This is not a fix, just a diagnostic test.
sub Zerox
{
if ($multiple == 0){$end = 1;}
until ($multiple == 0)
{
print &quot;m is $multiple\n&quot;;
$i++;
$multiple[red]++[/red]; # previously $multiple--;
$zeros .= &quot;0&quot;;
}
$dialnu = ++$chars;
}


Then, I ran it like .....
D:\temp>perl junk.cgi user=me<return>

and I got,
m is -2
m is -1
USER = me
Cdate = Today
Died at junk.cgi line 16.
D:\temp>

So, the fact that 'user' came out as 'me' indicates that the input parsing is working.
I think the problem is probably in the looping. It goes infinite and you never see your output .......uh -oh thunderstorms.....power is blinking

' hope this submits OK

HTH


keep the rudder amid ship and beware the odd typo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top