Last thing I used in the cgi was:
$ifile ="/path/top.html";
open FILE, $ifile;
@o=<FILE>;
close FILE;
foreach (@o) {
print $_;
}
I'm sure this question has been asked before, but I can't find anything suitable on the site.
If someone could point me in the right direction it would be much appreciated.
Is there not a simple include command I can use like in PHP?
Bad header=Global symbol "$ifile" require: /usr/cgiwrap/cgiwrap
I now get this error:
Bad header=Bareword found where operator : /usr/cgiwrap/cgiwrap
#!/usr/bin/Perl [perl.com] -w
use strict;
#
my $ifile = "/path/top.html";
#
open ('TEMP', $ifile) or die("Can't open file $ifile: $!\n");
my @contents = <TEMP>;
close ('TEMP');
#
print @contents;
Andreas
How should I write the path to the include file?
The cgi script is in domain.com/cgi-bin and my header file is in domain.com/inc/top.html
No path I try works. I've tried ../inc/top.html /inc/top.html and also the full unix path /home/myfolders/etc/web/inc/ and even [domain.com...]
All of these generate the file not found error. Help! :(
open ('TEMP'
Why would this not work? Could it be a server config problem?
Still not working though. I just realised that I have some PHP in the inc files, so I guess this whole idea is doomed to failure. Unless I can include a PHP file in a CGI script?
<html>
<head>
<title>test</title>
</head>
<body>
woohoo!
</body>
</html>
I get the error:
malformed header from script. Bad header=<html>
This is really starting to get to me ;)
Yeah, thatīs my auto linking tool again. It turns p-h-p to PHP [php.net] and p-e-r-l to Perl [perl.com].
>>Unless I can include a PHP [php.net] file in a CGI script?
You could run the include file through the PHP [php.net] binary. Just change the line defining the filename to read like this:
my $ifile = "php4 -q /path/top.html¦";
Notice the pipe symbol after the filename. You need to adjust the name of the PHP [php.net] binary and might want to use an absolute path to it. The -q keeps PHP [php.net] from writing any headers.
Andreas
Got includes working with flat html files (woohoo!)
now i'm trying to pass my html include file (with php scripts) through the PHP binary. The output i'm getting is:
X-Powered-By: PHP/4.0.6 Content-type: text/html use strict; # my $ifile.....
Seems to be just printing out the perl script. Any ideas?
This is what I have:
#!/usr/bin/perl -w
use strict;
#
my $ifile = "/usr/bin/php -q ../inc/test.html¦";
#
open ('TEMP', $ifile) or die("Can't open file $ifile: $!\n");
my @contents = <TEMP>;
close ('TEMP');
#
print "Content-type: text/html\n\n";
print @contents;
The example I posted works for me using PHP [php.net] 4.1.2.
Andreas
How do I get my cgi scripts to be displayed with my site header and footer files. Is my best bet to stick at the include method above, or is there another way?