Quantcast

Forums | MacLife

You are not logged in.

#1 2007-11-10 3:59 pm

soulcrusher
Banned
From: Princetown, Jamaica
Registered: 2000-10-21
Posts: 3816

Safari issues with a simple cgi script

Dear All,

I have written a cgi script that reads a text file that contains one number (either 0 or 1) and does different things depending on the value of the file.

Here is the code

Code:

#!/usr/bin/perl 

$bit = "bit.txt";

# Flips the bit
   open(COUNT,"$bit") || die "Can't open file for reading: $!\n";
   $c = <COUNT> ;
   close(COUNT);
   if ($bit =~ /\n$/) {
      chop($c);
   }

if($c==1){

Do some html here.

}

else{

Do some other html here.

}

Even though the script runs fine in Firefox, it does not in Safari.

It works as expected in Safari if I load the page by pressing "return" in the address bar but if I press "reload" button it does something very weird: regardless of the value in the text file it runs the else{}.

Does anyone know what the problem might be?

Thanks.


"VERY HOT 20-year-olds in GAY ACTION FILMED BY BIG BREASTED CALIFORNIA BABE"

Offline

 

#2 2007-11-10 5:26 pm

Miles
Now I fight for wisdom!
Administrator
From: Michigan
Registered: 2001-07-21
Posts: 4506
Website

Re: Safari issues with a simple cgi script

Code:

# Don't do this:
"$bit"
# Do this:
$bit


if ($bit =~ /\n$/) {
   chop($c);
}
# $bit contains the name of the file, is that really what you meant to test?
# The above 3 lines can probably just be replaced with:
chomp($c);

soulcrusher wrote:

It works as expected in Safari if I load the page by pressing "return" in the address bar but if I press "reload" button it does something very weird: regardless of the value in the text file it runs the else{}.

That sounds impossible, but you haven't really given us enough information.  For one, you have the comment "Flips the bit", but no such "flipping" ever happens.

Offline

 

#3 2007-11-10 6:14 pm

soulcrusher
Banned
From: Princetown, Jamaica
Registered: 2000-10-21
Posts: 3816

Re: Safari issues with a simple cgi script

sorry. the original program had some flipping. this one doesn't.

Well it is not impossible because it happens.


"VERY HOT 20-year-olds in GAY ACTION FILMED BY BIG BREASTED CALIFORNIA BABE"

Offline

 

#4 2007-11-10 6:15 pm

soulcrusher
Banned
From: Princetown, Jamaica
Registered: 2000-10-21
Posts: 3816

Re: Safari issues with a simple cgi script

actually. let me update the commen.t

heh


"VERY HOT 20-year-olds in GAY ACTION FILMED BY BIG BREASTED CALIFORNIA BABE"

Offline

 

#5 2007-11-10 6:18 pm

soulcrusher
Banned
From: Princetown, Jamaica
Registered: 2000-10-21
Posts: 3816

Re: Safari issues with a simple cgi script

ok I changed "$bit" to $bit and the comment "Flip the bit" to "Read bit from file" and of course, the problem is still there.


"VERY HOT 20-year-olds in GAY ACTION FILMED BY BIG BREASTED CALIFORNIA BABE"

Offline

 

#6 2007-11-10 6:25 pm

soulcrusher
Banned
From: Princetown, Jamaica
Registered: 2000-10-21
Posts: 3816

Re: Safari issues with a simple cgi script

ok. It is dependent on the html code in the if/else statements. It only seems to happen when I have frames in them.


"VERY HOT 20-year-olds in GAY ACTION FILMED BY BIG BREASTED CALIFORNIA BABE"

Offline

 

#7 2007-11-10 11:38 pm

Miles
Now I fight for wisdom!
Administrator
From: Michigan
Registered: 2001-07-21
Posts: 4506
Website

Re: Safari issues with a simple cgi script

When you refresh a frameset in Safari, it will reload the current frames; if you press return in the address bar, it will load the original frames (as specified in the frameset).

Offline

 

#8 2007-11-11 12:34 pm

soulcrusher
Banned
From: Princetown, Jamaica
Registered: 2000-10-21
Posts: 3816

Re: Safari issues with a simple cgi script

does firefox work differently?

Is there anyway to change this behavior?

Thanks.


"VERY HOT 20-year-olds in GAY ACTION FILMED BY BIG BREASTED CALIFORNIA BABE"

Offline

 

#9 2007-11-11 1:15 pm

Booksley
Zombie Genocidest
From: Toronto, Ontario
Registered: 2001-02-16
Posts: 5037

Re: Safari issues with a simple cgi script

Don't use frames?

Frames annoy me.

Offline

 

#10 2007-11-11 3:56 pm

Scott
Zombie Gorilla
From: Oregon
Registered: 2002-12-07
Posts: 3446
Website

Re: Safari issues with a simple cgi script

Sounds like it is just being cached.  The cgi is irrelevant as none of that is executed or even seen client side.

• Don't use frames
• Set expiration via headers
• Know how your server caches and sets headers.


http://www.greatgamesexperiment.com/images/logo_kit/468x60-Blue.gif

Offline

 

#11 2007-11-11 10:38 pm

soulcrusher
Banned
From: Princetown, Jamaica
Registered: 2000-10-21
Posts: 3816

Re: Safari issues with a simple cgi script

the reason why i want to use frames is so that when the browser refreshes, regardless of the frame they are in, it runs the original script.

Is there another way to do this?

Or should I just only allow the shifters (users) to use Firefox?

What's expiration?

Last edited by soulcrusher (2007-11-11 11:57 pm)


"VERY HOT 20-year-olds in GAY ACTION FILMED BY BIG BREASTED CALIFORNIA BABE"

Offline

 

#12 2007-11-12 11:36 pm

Light Speed
Doubter of Einstein
Registered: 2002-08-17
Posts: 3694

Re: Safari issues with a simple cgi script

Frames were bad 8 years ago.

Google hates frames
Users hate frames

Header expiration info can be found here

Offline

 

Board footer

Powered by PunBB 1.2.6
© Copyright 2002–2005 Rickard Andersson