new line (again) - works on my computer but not my hosts server?!?!? (Posted by Justin Stayton)

Justin S's picture

They have: 2,076 posts

Joined: Jun 1999

i have a script that will print the ip address of the visitor, and then print a new line. it works fine on my computer using sambar server, but on linux it prints  in between each ip. whats wrong?

the code:

## Your IP address
$yourip = "000.000.000.000";

## Visitors IP address
$visitorip = $ENV{'REMOTE_ADDR'};

## Path to the counter file
$countfile = "/home/fireburn/ftp/cgi-bin/count/count.dat";

## Path to the log file
$logfile = "/home/fireburn/ftp/cgi-bin/count/log.dat";

print "Content-type: text/html\n\n";
open(COUNT, "$countfile");
$count = <COUNT>;
$count++;
close (COUNT);

open(COUNT, ">$countfile");
print COUNT "$count";
close (COUNT);

open(LOG, "$logfile");
$log = <LOG>;
close (LOG);

open(LOG, ">>$logfile");
print LOG "$visitorip";
print LOG "\n";
close (LOG);

print "$count";

----------
[red]FireBurn Web Publishing[/red]: fireburn.com
Low cost web design, graphic design, and more!

They have: 69 posts

Joined: Apr 1999

It seems to me like the file is being created on the linux server, and you are downloading it through FTP to a windows system. In that case, download the file in ASCII mode instead of binary, and the file should have the correct new lines instead of these squares.

----------
Reviews of the best resources for webmasters in your e-mail every week!
Subscribe for [red]FREE[/red] by going to http://www.web-reviews.com/

They have: 850 posts

Joined: Jul 1999

OK, this is a long shot, but try combining
print LOG "$visitorip";
print LOG "\n";

to make
print LOG "$visitorip\n";

----------
[red][Rob P][/red]
[[email protected]]--[[icq]16560402[/icq]]

Justin S's picture

They have: 2,076 posts

Joined: Jun 1999

Thats what I'm doing wrong, thanks Frederico! To robp: I tried that before but for some reason it didnt work...

----------
[red]FireBurn Web Publishing[/red]: fireburn.com
Low cost web design, graphic design, and more!

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.