httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Arnie & Georgia Stender <aags...@bigriver.net>
Subject Re: [users@httpd] Newbe needs help passing form data
Date Thu, 29 Dec 2005 19:39:22 GMT
Hi Aaron,
I'm sorry, I must not have expressed myself properly. I'm not having a 
problem with parsing the data, I'm not getting any data to parse. The 
server is not sending anything (CONTENT_LENGTH->0) to the STDIN of the 
script nor is it setting the QUERY_STRING environment variable. I think 
I have a server configuration issue but I can't find any place to turn 
it on. From everything I have read passing the data should be automatic 
once you have got the server configured to run the CGI. I also don't 
know enough about the inner workings of Apache to know for sure if it is 
actually configuration or if maybe it's the way I wrote the HTML. My 
form tag looks like everything I have seen in the books I have. <form 
method="POST" action="/cgi-bin/env.pl"> From what I have, that should do 
it for the HTML end of things.

Arnie

Wagner, Aaron wrote:

>>-----Original Message-----
>>From: Arnie & Georgia Stender [mailto:aags777@bigriver.net] 
>>Sent: Thursday, December 29, 2005 12:22 PM
>>To: users@httpd.apache.org
>>Subject: [users@httpd] Newbe needs help passing form data
>>
>>Hello,
>>    I am setting up my own Internet presence starting with 
>>DNS and HTML 
>>servers. I am teaching myself (as much as possible) how to write HTML 
>>from scratch. Below you will find the server $ENV variables 
>>which will 
>>describe versions of the server etc. This is running on Linux 
>>(LFS) 6.0 
>>server.  I have looked through at least the archives for this 
>>month and 
>>not found an answer to my problem as well as a number of books on the 
>>subject of writing CGI (perl). So I ask you:
>>I have written a small HTML with a three field form that is 
>>supposed to 
>>pass the data to a perl script which in turn writes a dynamic 
>>HTML page 
>>based on the input to the form and sends it back to the browser. 
>>According to all I have read if I use method==POST the form data is 
>>supposed to be sent to the script via STDIN and if I use 
>>method==GET the 
>>data is sent via the $ENV{QUERY_STRING} variable. When using POST the 
>>amount of data being sent is available in the $ENV{CONTENT_LENGTH} 
>>variable. I have enabled everything I can find to run CGI on 
>>the server 
>>but I can not get the server to send any information to the script. I 
>>created the perl script from the online Apache manual to dump all the 
>>variables it is passing and the QUERY_STRING is empty and if 
>>the form is 
>>using POST the CONTENT_LENGTH==0. I am about 90% certain that I am 
>>missing something in the configuration file but after days of looking 
>>and reading I have not found out what it is. Running 'perl -w script' 
>>with a QUERY_STRING environment variable set equal to good 
>>data produces 
>>a good looking HTML output so I will go out on a limb and say the 
>>problem is not in the perl script. So, can anybody tell me what I am 
>>missing? BTW, the CGI script does produce the static portion 
>>of the HTML 
>>so the script is running just not getting the form data. Thanks in 
>>advance for any help you can give to point me in the right direction. 
>>Below is a sanitized output from the Apache ENV dump script.
>>
>>Arnie
>>
>>SCRIPT_NAME --> /cgi-bin/env.pl
>>SERVER_NAME --> stender4.local
>>HTTP_REFERER --> http://stender4.local/arnie.html
>>SERVER_ADMIN --> aags777@bigriver.net
>>HTTP_ACCEPT_ENCODING --> gzip,deflate
>>HTTP_CONNECTION --> keep-alive
>>REQUEST_METHOD --> POST
>>CONTENT_LENGTH --> 0
>>HTTP_ACCEPT --> 
>>text/xml,application/xml,application/xhtml+xml,text/html;q=0.9
>>    
>>
>,text/plain;q=0.8,image/png,*/*;q=0.5
>  
>
>>SCRIPT_FILENAME --> /usr/local/apache2/cgi-bin/env.pl
>>SERVER_SOFTWARE --> Apache/2.0.54 (Unix)
>>HTTP_ACCEPT_CHARSET --> ISO-8859-1,utf-8;q=0.7,*;q=0.7
>>QUERY_STRING -->
>>REMOTE_PORT --> 34615
>>HTTP_USER_AGENT --> Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.7) 
>>Gecko/20050416 Fedora/1.0.3-1.3.1 Firefox/1.0.3
>>SERVER_PORT --> 80
>>SERVER_SIGNATURE -->
>>Apache/2.0.54 (Unix) Server at stender4.local Port 80
>>
>>HTTP_ACCEPT_LANGUAGE --> en-us,en;q=0.5
>>REMOTE_ADDR --> 192.168.77.221
>>HTTP_KEEP_ALIVE --> 300
>>CONTENT_TYPE --> application/x-www-form-urlencoded
>>SERVER_PROTOCOL --> HTTP/1.1
>>PATH --> /bin:/usr/bin:/sbin:/usr/sbin
>>REQUEST_URI --> /cgi-bin/env.pl
>>GATEWAY_INTERFACE --> CGI/1.1
>>SERVER_ADDR --> 192.168.77.224
>>DOCUMENT_ROOT --> /usr/local/apache2/htdocs
>>HTTP_HOST --> stender4.local
>>
>>
>>    
>>
>Here is a script we are using now.  It is passing variables into this
>perl script.  Hope it helps you
>
>
>#! D:/WebCore2/perl/bin/perl.exe -w
>
>use CGI qw(:standard);
>use Net::Telnet;
>
>$|=1;
>
>my $WebP = new CGI;
>print $WebP->header;
>
>my $telnet;
>my $output;
>my $function;
>my $remoteServer;
>my $pageLink =
>"http://esystems.bankofamerica.com/Tools/_PagingForm/pagingform.php?mess
>=Oncall%3APlease%20call%20eSystems%20re%3A%20EWAA%20sev%201%20issue&dire
>nt=G00002002&Ntype=U";
>my $pageLinkSev2 =
>"http://esystems.bankofamerica.com/Tools/_PagingForm/pagingform.php?mess
>=Oncall%3APlease%20call%20eSystems%20re%3A%20EWAA%20sev%202%20issue&dire
>nt=G00002002&Ntype=U";
>#my $function = "diskspace";
>#my $remoteServer = "cwartxd01";
>##$function options = ping, diskspace, CPU, smservauth, smservaz,
>smservadm, smservacct
>## page group link
>http://esystems.bankofamerica.com/Tools/_PagingForm/pagingform.php?mess=
>Oncall%3APlease%20call%20eSystems%20re%3A%20EWAA%20sev%201%20issue&diren
>t=G00002002&Ntype=U
>
>if (($WebP->param("function") eq '') || ($WebP->param("remoteServer") eq
>'')){
>	print "<form>";
>	if ($WebP->param("function") eq ''){
>		print "function:";
>		print "<input type=text name=function
>value='".$WebP->param("function")."'><br>";
>	}else{
>		print "<input type=hidden name=function
>value='".$WebP->param("function")."'><br>";
>	}
>	if ($WebP->param("remoteServer") eq ''){
>		print "Server:";
>		print "<select name=remoteServer>\n";
>		print "<option>cwartxp05</option>\n";
>		print "<option>cwartxp06</option>\n";
>		print "<option>cwartxp07</option>\n";
>		print "<option>cwasfop04</option>\n";
>		print "<option>cwasfop05</option>\n";
>		print "<option>cwasfop06</option>\n";
>		print "<option>cwasfop07</option>\n";
>		print "<option>cwartxd01</option>\n";
>		print "</select>\n";
>	}else{
>		print "<input type=hidden name=remoteServer
>value='".$WebP->param("remoteServer")."'><br>";
>	}
>	print "<input type=submit>";
>	print "</form>";
>	exit;
>}else{
>	## pull the query string off the URL
>	$function = $WebP->param("function");
>	$remoteServer = $WebP->param("remoteServer");
>}
>
>
>print "Function: $function<br>";
>print "Remote Server: $remoteServer<br><br>";
>
>print "<html>\n";
>print "<head><title>Telnet</title></head>\n";
>print "<body bgcolor=\"#FFFFFF\">\n";
>
>######log in to server#################
>$telnet = new Net::Telnet (Timeout=>30,
>	
>Errmode=>'return'
>	
>);
>$telnet->open($remoteServer);
>$telnet->waitfor('/login: *$/i');
>$telnet->print ('xxxxxx');
>$telnet->waitfor('/Password: *$/i');
>$telnet->print ('xxxxxxx');
>$telnet->waitfor('/[\$>] $/');
>my $err = $telnet->errmsg;
>if ($err ne ''){
>	print "Error code:  $err";
>	die();
>}
>
>#########start ping#############
>if($function eq 'ping'){
>	my $cmd = "ping $remoteServer > ping.txt",;
>	system $cmd;
>	open(RESUL, "ping.txt");
>	my $pingTxt;
>	while(<RESUL>){
>		$pingTxt .= $_;
>	}
>	print pre($pingTxt),br,br;
>
>	$pingTxt =~ /Sent = (\d).*Received = (\d)/i;
>	if($1 != ''){
>		if ($1 == $2){
>			print b("Server is Pinging at 100%");
>		}elsif($2 < 4 && $2 > 0){
>			print "Server is Pinging, but less than 100%";
>		}elsif($2 == 0){
>			print "Server is not Pinging";
>			print "Page the EWAA Oncall<br>\n";
>			print "<input type=button value='Page EWAA
>Oncall' onClick=\"window.open('".$pageLink ."', 'ccwindow', 'left=100,
>top=700, height=800, width=700,
>dependent=no,directories=no,hotkeys=no,menubar=no,personalbar=no,resizab
>le=yes,scrollbars=yes,status=no')\"><br>\n";
>		}
>	}else{
>		$pingTxt =~ /Unknown host/i;
>		print "Unknown Host";
>		print "Page the EWAA Oncall<br>\n";
>		print "<input type=button value='Page EWAA Oncall'
>onClick=\"window.open('".$pageLink ."', 'ccwindow', 'left=100, top=700,
>height=800, width=700,
>dependent=no,directories=no,hotkeys=no,menubar=no,personalbar=no,resizab
>le=yes,scrollbars=yes,status=no')\"><br>\n";
>
>	}
>	close RESUL;
>}
>#########end ping#############
>
>#########verify diskspace mode#############
>if($function eq 'diskspace'){
>	my $cmd = "df -k /opt ";
>	$telnet->print($cmd);
>	($output2) = $telnet->waitfor('/[\$>]/i');
>	print hr({-width=>'80%'});
>	print pre("$output2\n");
>	print hr({-width=>'80%'});
>	if ($output2 =~ /(\d\d%)/){
>		print "disk space used: <b>$1</b>\n<br>";
>		if ($1 > 90){
>			print "blow up!!";
>			print "Page the EWAA Oncall<br>\n";
>			print "<input type=button value='Page EWAA
>Oncall' onClick=\"window.open('".$pageLink ."', 'ccwindow', 'left=100,
>top=700, height=800, width=700,
>dependent=no,directories=no,hotkeys=no,menubar=no,personalbar=no,resizab
>le=yes,scrollbars=yes,status=no')\"><br>\n";
>		}else{
>			print "Disk space within range."
>		}
>	}
>}
>#########end disk space#############
>
>#########start CPU Util#############
>if($function eq 'CPU'){
>
>	my $log = "Server:
>$remoteServer\n<####################################################>\n"
>;
>	my $cnter = 0;
>	my $bool_state;
>	$cmd = "cat vmstatResults";
>	$telnet->print($cmd);
>	($output2) = $telnet->waitfor('/[\$>] $/i');
>
>	@output2 = split("\n", $output2);
>	## shift off the top 4 lines
>	## and last 1 line
>	print "Start Time: ".$output2[1]."<br>";
>	$log .= "Start Time: ".$output2[1].".\n VMSTAT 60 30 was running
>on server doing 60 second checks for up to 30 minutes.\nThese are the
>results\n";
>	shift @output2;
>	shift @output2;
>	shift @output2;
>	shift @output2;
>	pop @output2;
>	foreach $row (@output2){
>		## every 20 rows, vmstat puts out the header colomn
>names again this will skip them
>		if ($row =~ /(\d+)$/ || $bool_state != 1){
>			$cnter++;
>			##print "$row - $1\%<br>";
>			if ($1 < 100){
>				print "$1\% - CPU available below 10%
>threshold\n";
>				$log .= "$1\% - CPU available below 10%
>threshold\n";
>			}else{
>				print "$1\% - CPU available above
>10%\nVMSTAT stopped.\n";
>				$log .= "$1\% - CPU available above
>10%\nVMSTAT stopped.\n";
>				$log .=
>"<####################################################>";
>				$bool_state = 1;
>				$cmd = "ps -ef|grep smuser|grep vmstat";
>				$telnet->print($cmd);
>				($output2) =
>$telnet->waitfor('/[\$>]/');
>				##print pre("$output2<br>");
>				if ($output2 =~ /\bsmuser\b +(\d+).+\d
>+vmstat \d+ \d+/i){
>					##print "Process ID for vmstat:
>$1<br>\n";
>					my $cmd = "kill -9 $1";
>					##print b($cmd);
>					$telnet->print($cmd);
>					($output2) =
>$telnet->waitfor('/[\$>]/');
>					print "Minutes took to clear:
>$cnter<br>";
>				}
>			}
>		}
>	}
>	if ($bool_state == 1){
>		print "Server CPU cleared up<br>";
>		$log .= "Minutes took to clear: $cnter<br>";
>	}else{
>		print "Server CPU remains high after $cnter
>minutes<br>";
>	}
>	if ($cnter < 10 && $bool_state == 1){
>		print "CPU cleared within 10 minutes, no action
>required\n";
>	}elsif (($cnter > 10 && $cnter < 30) && $bool_state == 1){
>		print
>start_form(-action=>'/Public/_eMail/ProcessMail.php', -method=>'get');
>		print hidden(-name=>logResults, -value=>$log);
>		print hidden(-name=>SendType, -value=>EWAATool);
>		print submit(-name=>Submit, -value=>'Send Auto Email to
>EWAA Group');
>	}elsif ($cnter > 30){
>		print b("CPU has not cleared within 30 minutes\n");
>		print b("Page the EWAA Oncall<br>\n");
>		print "<input type=button value='Page EWAA Oncall'
>onClick=\"window.open('".$pageLink ."', 'ccwindow', 'left=100, top=700,
>height=800, width=700,
>dependent=no,directories=no,hotkeys=no,menubar=no,personalbar=no,resizab
>le=yes,scrollbars=yes,status=no')\"><br>\n";
>		##print $log;
>		print
>start_form(-action=>'/Public/_eMail/ProcessMail.php', -method=>'get');
>		print hidden(-name=>logResults, -value=>$log);
>		print hidden(-name=>SendType, -value=>EWAATool);
>		print submit(-name=>Submit, -value=>'Send Auto Email to
>EWAA Group');
>	}else{
>		print "<input type=button value='Refresh'
>onClick=\"location.reload()\">";
>	}
>}
>#########end CPU Util#############
>
>#########start Service#############
>if($function eq 'smservauth' || $function eq 'smservaz' || $function eq
>'smservadm' || $function eq 'smservacct'){
>	my $cmd = "ps -ef|grep smuser|grep $function";
>	$telnet->print($cmd);
>	($output2) = $telnet->waitfor('/[\$>]/');
>	print hr({-width=>'80%'});
>	print pre("$output2\n");
>	print hr({-width=>'80%'});
>	$output2 =~ /\bsmuser\b +(\d+).+\d +\b$function\b/ig;
>	print "Process ID for $function: $1<br>\n";
>	if ($1 eq ''){
>		print "process not running<br>\n";
>		print "Page the EWAA Oncall<br>\n";
>		print "<input type=button value='Page EWAA Oncall'
>onClick=\"window.open('".$pageLink ."', 'ccwindow', 'left=100, top=700,
>height=800, width=700,
>dependent=no,directories=no,hotkeys=no,menubar=no,personalbar=no,resizab
>le=yes,scrollbars=yes,status=no')\"><br>\n";
>	}else{
>		print "If sitescope is still erroring, kill Process
>$function  on  $remoteServer<br>";
>		print "<input type=button value='Kill $function'
>onClick=\"window.location='EWAATool.pl?function=kill&oldfunction=$functi
>on&remoteServer=$remoteServer&oldPID=$1'\">";
>	}
>}
>#########end Service#############
>
>#########start kill Service#############
>if($function eq 'kill'){
>	my $log = "Server:
>$remoteServer\n<####################################################>\n"
>;
>	$oldPID = $WebP->param("oldPID");
>	$oldfunction = $WebP->param("oldfunction");
>	my $cmd = "kill -9 $oldPID";
>	##start a log string for email and to DB log
>	$log .= "$cmd\n";
>	print b($cmd);
>	$telnet->print($cmd);
>	($output2) = $telnet->waitfor('/[\$>]/');
>	$log .= "$output\n";
>	$cmd = "ps -ef|grep smuser|grep $oldfunction";
>	##$log .= "$cmd\n";
>	$telnet->print($cmd);
>	($output2) = $telnet->waitfor('/[\$>]/');
>	$log .= "$output2\n";
>	print hr({-width=>'80%'});
>	print pre("$output2");
>	print hr({-width=>'80%'});
>	$output2 =~ /\bsmuser\b +(\d+).+\d +\b$oldfunction\b/ig;
>	if ($1 eq ''){
>		print "Process Not Running, Page EWAA oncall<br>\n";
>		print "Page the EWAA Oncall<br>\n";
>		print "<input type=button value='Page EWAA Oncall'
>onClick=\"window.open('".$pageLink ."', 'ccwindow', 'left=100, top=700,
>height=800, width=700,
>dependent=no,directories=no,hotkeys=no,menubar=no,personalbar=no,resizab
>le=yes,scrollbars=yes,status=no')\"><br>\n";
>	}elsif($1 ne $oldPID){
>		$cmd = "Process ID for $oldfunction: $1\n";
>		print $cmd;
>		$log .= "$cmd\n";
>		$cmd = "Service restarted with new PID\n";
>		print b($cmd);
>		$log .= $cmd .
>"<####################################################>";
>		print
>start_form(-action=>'/Public/_eMail/ProcessMail.php', -method=>'get');
>		print hidden(-name=>logResults, -value=>$log);
>		print hidden(-name=>SendType, -value=>EWAATool);
>		print submit(-name=>Submit, -value=>'Send Auto Email to
>EWAA Group');
>	}else{
>		print "Process did not restart<br>\n";
>		print "Page the EWAA Oncall<br>\n";
>		print "<input type=button value='Page EWAA Oncall'
>onClick=\"window.open('".$pageLink ."', 'ccwindow', 'left=100, top=700,
>height=800, width=700,
>dependent=no,directories=no,hotkeys=no,menubar=no,personalbar=no,resizab
>le=yes,scrollbars=yes,status=no')\"><br>\n";
>	}
>}
>#########end kill Service#############
>
>
>#####close connection#########
>$telnet->print ('exit');
>my $ok = $telnet->close;
>print "<br>\nEND";
>
>exit;
>
>
> 
>Thanx
>Aaron N Wagner
>Monitoring Systems and Network Tools
>CCO-Command Center Operations
>804.515.6298
>
>---------------------------------------------------------------------
>The official User-To-User support forum of the Apache HTTP Server Project.
>See <URL:http://httpd.apache.org/userslist.html> for more info.
>To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
>For additional commands, e-mail: users-help@httpd.apache.org
>
>
>
>  
>


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message