ignoranceisblis
11-13-2004, 02:53 AM
#I'm trying to make a CGI perl script to create a nre forum topic. if I change $outfile to an actual file location rather then a variable it will print the data to it, but that kinda makes the whole thing less dynamic. There is also about 250 other lines that I took out cause they are all working fine, I have a feeling the problem is in how I open COPYHANDLE2, if anyone out there canhelp me that would be really really great
#!/usr/bin/perl -wT
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use Fcntl qw(:flock :seek);
#most of this is just a make shift filter
my($title, $nametitle, %crazy);
my($space, $html, $html2, $table, $table2);
my($htmll, $htmll2, $tablee, $tablee2);
my($tr, $tr2, $trr, $trr2);
my($td, $td2, $tdd, $tdd2);
$space = "<font color=white>_</font>";
$html = "</html>";
$html2 = "<html>";
$htmll = "</HTML>";
$htmll2 = "<HTML>";
$table = "</table>";
$table2 = "<table>";
$tablee = "</TABLE>";
$tablee2 = "<TABLE>";
$tr = "<tr>";
$tr2 = "</tr>";
$trr = "<TR>";
$trr2 = "</TR>";
$td = "<td>";
$td2 = "</td>";
$tdd = "<TD>";
$tdd2 = "</TD>";
#input
$title = param('name');
$title =~ s/ /$space/g;
$nametitle = $title;
$title = param('name');
#filtering
$title =~ s/ //g;
$title =~ s/!//g;
$title =~ s/$html//g;
$title =~ s/$html2//g;
$title =~ s/$htmll//g;
$title =~ s/$htmll2//g;
$title =~ s/$table//g;
$title =~ s/$table2//g;
$title =~ s/$tablee//g;
$title =~ s/$tablee2//g;
$title =~ s/$tr//g;
$title =~ s/$tr2//g;
$title =~ s/$trr//g;
$title =~ s/$trr2//g;
$title =~ s/$td//g;
$title =~ s/$td2//g;
$title =~ s/$tdd//g;
$title =~ s/$tdd2//g;
$title =~ s/'//g;
$title =~ s/"//g;
$title =~ s/;//g;
#this is where I declared what $outfile is
my $titleend = "$title.shtml";
$outfile = "/var/www/cgi-bin/forums/$titleend";
$outfile = $outfile;
print header;
print start_html("New Thread");
#it will tell me what the filename is called and it's location but it won't create or edit the file, it says there is nothing there. It doesn't work even when there is already a file there, it does however work when I say open COPYHANDLE2,">>/actualt/file/location";
open COPYHANDLE2, >>$outfile or die "can't access $outfile:$!\n";
print COPYHANDLE2 "\n";
close(COPYHANDLE2);
open COPYHANDLE2, >$outfile or die "can't access $outfile:$!\n";
print COPYHANDLE2 $titleend;
print COPYHANDLE2 "\n";
print "<br><br>";
print "outfile:";
print $outfile;
print "<br><br>";
print "titleend:";
print $titleend;
print "<br><br>";
print "nametitle:";
print $nametitle;
print "<br><br>";
print COPYHANDLE2 $outfile;
print COPYHANDLE2 "\n";
print COPYHANDLE2 $nametitle;
print COPYHANDLE2 "\n";
close(COPYHANDLE2);
#if anyone can help you're my hero, I've been stuck at my desk for 2 days on the same 3 lines.
#!/usr/bin/perl -wT
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use Fcntl qw(:flock :seek);
#most of this is just a make shift filter
my($title, $nametitle, %crazy);
my($space, $html, $html2, $table, $table2);
my($htmll, $htmll2, $tablee, $tablee2);
my($tr, $tr2, $trr, $trr2);
my($td, $td2, $tdd, $tdd2);
$space = "<font color=white>_</font>";
$html = "</html>";
$html2 = "<html>";
$htmll = "</HTML>";
$htmll2 = "<HTML>";
$table = "</table>";
$table2 = "<table>";
$tablee = "</TABLE>";
$tablee2 = "<TABLE>";
$tr = "<tr>";
$tr2 = "</tr>";
$trr = "<TR>";
$trr2 = "</TR>";
$td = "<td>";
$td2 = "</td>";
$tdd = "<TD>";
$tdd2 = "</TD>";
#input
$title = param('name');
$title =~ s/ /$space/g;
$nametitle = $title;
$title = param('name');
#filtering
$title =~ s/ //g;
$title =~ s/!//g;
$title =~ s/$html//g;
$title =~ s/$html2//g;
$title =~ s/$htmll//g;
$title =~ s/$htmll2//g;
$title =~ s/$table//g;
$title =~ s/$table2//g;
$title =~ s/$tablee//g;
$title =~ s/$tablee2//g;
$title =~ s/$tr//g;
$title =~ s/$tr2//g;
$title =~ s/$trr//g;
$title =~ s/$trr2//g;
$title =~ s/$td//g;
$title =~ s/$td2//g;
$title =~ s/$tdd//g;
$title =~ s/$tdd2//g;
$title =~ s/'//g;
$title =~ s/"//g;
$title =~ s/;//g;
#this is where I declared what $outfile is
my $titleend = "$title.shtml";
$outfile = "/var/www/cgi-bin/forums/$titleend";
$outfile = $outfile;
print header;
print start_html("New Thread");
#it will tell me what the filename is called and it's location but it won't create or edit the file, it says there is nothing there. It doesn't work even when there is already a file there, it does however work when I say open COPYHANDLE2,">>/actualt/file/location";
open COPYHANDLE2, >>$outfile or die "can't access $outfile:$!\n";
print COPYHANDLE2 "\n";
close(COPYHANDLE2);
open COPYHANDLE2, >$outfile or die "can't access $outfile:$!\n";
print COPYHANDLE2 $titleend;
print COPYHANDLE2 "\n";
print "<br><br>";
print "outfile:";
print $outfile;
print "<br><br>";
print "titleend:";
print $titleend;
print "<br><br>";
print "nametitle:";
print $nametitle;
print "<br><br>";
print COPYHANDLE2 $outfile;
print COPYHANDLE2 "\n";
print COPYHANDLE2 $nametitle;
print COPYHANDLE2 "\n";
close(COPYHANDLE2);
#if anyone can help you're my hero, I've been stuck at my desk for 2 days on the same 3 lines.