Now this script works fine but when this script sends the target script source code to the web browser the cgi source code in the script gets parsed as html code. Is there anyway I can use this method and not have the web browser parse the cgi source code as html code and simply display as text?#!/usr/bin/perl -w use strict; use CGI qw(param); my $cgi = new CGI; my @param = $cgi->param(); my $path = "/home/master/webroot/newdesign/scripts/"; my @source; error() unless @param; my $full = $path.$param[0]; if (-e $full) { open(FILE, "$full") || error(); @source = <FILE>; close(FILE); print "Content-type: text/html; charset=ISO-8859-1\n\n"; print <<last; <html> <head><title>$param[0]</title> </head> <body bgcolor="#000000" text="#808080" leftmargin="0" marginwidth="0" +topmargin="0" marginheight="0"> <table border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td> last for (@source) { print; print "<br>\n"; } print <<last2; </td> </tr> </table> </body> </html> last2 }else{ error(); } sub error { print "Content-type: text/html; charset=ISO-8859-1\n\n"; print <<end; <html> <head><title>Error!</title> </head> <body bgcolor="#000000" text="#808080" leftmargin="0" marginwidth="0" +topmargin="0" marginheight="0"> <table border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td> There was an error while trying to post script source! </td> </tr> </table> </body> </html> end exit(0); }
Also along the same lines all the scripts source code formatting (spaces, indentation, basically all whitespace) gets stripped from the source code and all source code is aligned with the left margin. This is not as big of a deal but I would like the scripts to keep their formatting after being sent to the browser.
You can see this script in action and actually see the indications I am talking about above in action at the production server link that follows: http://4.46.66.37/master/webroot/newdesign/scripts.htm
In reply to issues displaying cgi script source? by Elijah
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |