![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 | |
|
Professional Programmer
Join Date: May 2006
Location: UK - London
Posts: 329
Rep Power: 3
![]() |
Script problem or platform conversion error
i wrote this script on my windows box:
use CGI;
$results=new CGI;
$comment=$results->param("comments");
$name=$results->param("name");
open(DAT,">>Comments.txt");
$i=60;
$j=0;
$szlen=length $comment;
print DAT $name;
print DAT "\n";
if($szlen<60)
{
print DAT $comment."\n";
}
else
{
while($i<=$szlen)
{
print DAT substr($comment,$j,$i)."\n";
$j=$i;
$i+=60;
}
if($i<$szlen)
{
print DAT substr($comment,$i,$$szlen-$i)."\n";
}
}
close(DAT);
print "Content-type:text/html\n\n";and i uploaded to my hosting company's linux server, but instead of getting a newline were i was expecting a new line i got this small rectangle between the texts, for example this the output on my windows box: Test Test and this is the output on my server's linux box: Test Test can some please tell me why this is. I thank you in advance for your replies.
__________________
Quote:
|
|
|
|
|
|
|
#2 | |
|
Professional Programmer
Join Date: May 2006
Location: UK - London
Posts: 329
Rep Power: 3
![]() |
Redirect Problem
okay after some googling and alot of cursing and head scatching i found an alternative to this problem, which seemed to help, so decided to test this, so halfway through my testing i said "i wonder if i refresh the page what would happen", well i found out, it wrote to the file again and the same thing was outputted twice, then i thought how about i redirect the user to another page, so i tried, but no matter what page i redirected the user to i ke getting the 404 page not found page, i even tried using full paths, but still 404,does any body know what on earth is happening here, any help is greatley appreciated.
Regards, Kruptof
__________________
Quote:
|
|
|
|
|
|
|
#3 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 4
![]() |
Windows uses "\r\n" as its linebreak. Linux and other Unix-like systems use "\n". A simple substitution should convert between the two (s/\n/\r\n/g).
As for the redirect - can I see your redirection code? |
|
|
|
|
|
#4 | |
|
Professional Programmer
Join Date: May 2006
Location: UK - London
Posts: 329
Rep Power: 3
![]() |
thanks Arevos......................ok here is the code for the redirection.....no matter what address i put in i will always get the 404 error:
#!/usr/bin/perl
use CGI;
$results=new CGI;
$comment=$results->param("comments");
$name=$results->param("name");
open(DAT,">>Comments.txt");
$i=60;
$j=0;
$szlen=length $comment;
print DAT $name."<br>";
print DAT "\n";
if($szlen<60)
{
print DAT $comment."<br>";
}
else
{
while($i<=$szlen)
{
print DAT substr($comment,$j,$i)."<br>";
$j=$i;
$i+=60;
}
if($i<$szlen)
{
print DAT substr($comment,$i,$$szlen-$i)."<br>";
}
}
close(DAT);
open(DAT,"Comments.txt");
my @cont=<DAT>;
close(DAT);
print "location: home.html"; #<- this is the RELOCATion PART
print "Content-type:text/html\n\n";
__________________
Quote:
|
|
|
|
|
|
|
#5 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 4
![]() |
Try:
Perl Syntax (Toggle Plain Text)
|
|
|
|
|
|
#6 | |
|
Professional Programmer
Join Date: May 2006
Location: UK - London
Posts: 329
Rep Power: 3
![]() |
still gettting the same error, here is the new code:
#!/Perl/bin/perl
use CGI;
$results=new CGI;
$comment=$results->param("comments");
$name=$results->param("name");
open(DAT,">>Comments.txt");
$i=60;
$j=0;
$szlen=length $comment;
print DAT $name."<br>";
print DAT "\n";
if($szlen<60)
{
print DAT $comment."<br>";
}
else
{
while($i<=$szlen)
{
print DAT substr($comment,$j,$i)."<br>";
$j=$i;
$i+=60;
}
if($i<$szlen)
{
print DAT substr($comment,$i,$$szlen-$i)."<br>";
}
}
close(DAT);
open(DAT,"Comments.txt");
my @cont=<DAT>;
close(DAT);
$url="/test\.html";
print "Status: 302 Moved\nLocation: $url";
print "Content-type:text/html\n\n";
__________________
Quote:
|
|
|
|
|
|
|
#7 | |
|
Professional Programmer
Join Date: May 2006
Location: UK - London
Posts: 329
Rep Power: 3
![]() |
after some googling and some trails and errors i have found this:
print "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 3.2//EN'>"; print "<html><head><title>$page_title</title>"; print "<META HTTP-EQUIV='Refresh' CONTENT='0; URL=http://www.somedomain.com'>"; print "</HEAD><BODY></BODY></HTML>"; there is still some thing wrong with this html but i will post that in the html forum.......thank you everyone for the help.
__________________
Quote:
|
|
|
|
|
|
|
#8 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 4
![]() |
What happens if you put the full URL in? And what happens when you go to said URL normally?
|
|
|
|
|
|
#9 | |
|
Professional Programmer
Join Date: May 2006
Location: UK - London
Posts: 329
Rep Power: 3
![]() |
i got an error 404
__________________
Quote:
|
|
|
|
|
|
|
#10 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 4
![]() |
In both cases? Then surely it's nothing to do with the redirect script, but because the URL you're going to does not exist.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| C# corruption!!! | Kilo | C++ | 32 | May 21st, 2006 8:44 PM |
| Masm | rsnd | Assembly | 4 | May 20th, 2006 9:05 PM |
| cgi/perl script + IE problem | joyceshee | Perl | 2 | Jan 24th, 2006 11:10 AM |
| libraries | matko | C | 1 | Jan 22nd, 2006 2:12 PM |
| Problem with Perl script | eclipsed4utoo | Perl | 1 | Dec 2nd, 2005 1:33 PM |