hi all, i am a novice trying to run a perl script on apache for a real time dat aquisition system. i am using a perl script developed by a professor in india who wrote a book on programming the parallel port, which i have attached. the thing is i don't know how to run the script on apache, well i have tried and failed. i installed apache on a laptop and was able to launch the test page: "http://localhost" successfully. in accordance with the requirements for running mod_perl, i created a directory under httpd called "perl" in which i stored the script. according to redhat's linux 6.2 apache/ssl documentation, mod_perl is ready to run once the server is launced and there is no need for any changes in httpd.conf hoping to run the script i entered the URL: http://localhost/perl/Read_dat.perl/ and got the reponse: Forbidden "you don't have permission to access /perl/Read_dat.perl/ on this server. Please assist in the steps necessary to be able to successfully run this script. thanks Keletso __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/
#!/usr/bin/perl #read_data_average.perl # Number of Sample points to make running average of is supplied as a command line argumnt $num_samples=$ARGV[0]; # Set minimum and maximum to arbitrarily high and low values respectively $min_temp = 100.0; $max_temp = -100.0; @minimum=split(/ +/,localtime()); $min_temp_time=$minimum[3]; $min_temp_date=$minimum[1]." ".$minimum[2]; @maximum=split(/ +/,localtime()); $max_temp_time=$maximum[3]; $max_temp_date=$maximum[1]." ".$maximum[2]; # Infinite Loop to run as a daemon for(;;) { # Open temperature.dat for input (contains $num_samples lines of the format # temperature Sun Jul 28 00:00:00 1996 open(INFILE,"<temperature.dat") || die "Can't open inputfile"; # Read all the data into a single array # Each element of array contains one line of file @inputs=<INFILE>; close(INFILE); # $num_lines contains number of lines in the file $num_lines=@inputs; # Check to see if the number of lines is greater than number of sample points to average over if ($num_lines >= $num_samples) { # If true then average over the temperature field and also find the minimum and maximum values for temperature. # Initialize counter,sum and average $counter = 1; $sum = 0.0; $average = 0.0; while($counter <= $num_samples) { # Split each element of input array on whitespace @data = split(/ +/,$inputs[$num_lines-$counter]); # Extract the first field as temperature $temperature = $data[0]; $data_time = $data[4]; $data_date= $data[2]." ".$data[3]; if ($data_date ne $min_temp_date) { $min_temp_date=$data_date; $min_temp=$temperature; $min_temp_time=$data[4]; $max_temp_date=$data_date; $max_temp=$temperature; $max_temp_time=$data[4]; } # Find the minimum and maximum temperature of num_sample points if ($temperature < $min_temp) { $min_temp = $temperature; $min_temp_time=$data_time; $min_temp_date=$data_date; } if ($temperature > $max_temp) { $max_temp = $temperature; $max_temp_time=$data_time; $max_temp_date=$data_date; } $sum += $temperature; $counter++; } # Compute average $average = $sum/($counter-1); $current_time=localtime; # Open output file in HTML format (Weather.html) open(OUTFILE,">Weather.html") || die "can't write output HTML file\n"; print OUTFILE "<HTML><TITLE>\n"; print OUTFILE " The Weather at IUCAA\n"; print OUTFILE "</TITLE>\n"; print OUTFILE "<BODY bgcolor=\"\#000000\" text=\"\#ffffff\" link=\"\#00ff00\" alink=\"\#ff0000\" vlink=\"\#ffff00\">\n"; print OUTFILE "<CENTER>\n<HR>\n"; print OUTFILE "<H1>The Weather at IUCAA </H1>"; print OUTFILE "<HR></CENTER>\n"; print OUTFILE "<FONT text=\"\#ff0033\" >Time of record (IST) is $current_time</FONT>\n<BR>\n"; printf OUTFILE ("<FONT text=\"\#ff0033\" >Average Temperature for the past $num_samples minutes:\t %3.1f degrees Celsius</FONT>\n",$average); printf OUTFILE ("<FONT text=\"\#ff0033\" ><HR>\nMinimum Temperature:%3.1f degrees Celsius at $min_temp_time on $min_temp_date\n<HR>\nMaximum Temperature:%3.1f degrees Celsius at $max_temp_time on $max_temp_date<HR></FONT>\n",$min_temp,$max_temp); print OUTFILE "<BR>\n"; print OUTFILE "<BR>\n"; print OUTFILE "<BR>\n"; print OUTFILE "<A HREF=\"http://iucaa.iucaa.ernet.in/~ilab/instrumentation.html\">Back to Instrumentation</A>\n"; print OUTFILE "</BODY></HTML>\n"; close(OUTFILE); # Move Weather.html ~ilab/public_html system("mv Weather.html .."); } else { sleep(15*60); } # End of If $numlines < $numsamples condition sleep(15*60); } # End infinite loop #Listing 2
#!/bin/sh echo "Cleaning evrything\n" make clean echo "Starting Temperature reader \n" ./adc_read 60 15 7 & sleep 15m echo "Starting HTML constructor \n" ./read_data_average.perl 15 &