Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Cgi giveing me a headach (Read 5133 times)
throesch
God Member
*****
Offline


I will own you all. will
you be on the good list?

Posts: 561
Location: Arab
Joined: Nov 9th, 2001
Gender: Male
Cgi giveing me a headach
Apr 10th, 2002 at 12:46am
Print Post  
hey ppl i dont understand why im getting this error.

CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:

Could not open file! at D:\home\Default\20inchbmx.com\htdocs\cgi-bin\psdwire\udgnet.pl line 7.


Code
Select All
#!/usr/bin/perl
#######################
# Underground network #
#######################

$data_file="data.txt";
open(BOT, $data_file) || die("Could not open file!");
@raw_data=<BOT>;
close(BOT);
print "Content-type: text/html\n\n";
print "<HTML><BODY>";
foreach $BOT (@raw_data)
{
 chop($BOT);
 ($hubs,$user,$total)=split(/\|/,$BOT);
 print "<b>Total Hubs:</b> $hubs ";
 print "<b>Total Users:</b> $user ";
 print "<b>Total Files Shared:</b> $total";
}
 print "</BODY></HTML>";

 



line 7 is open(BOT, $data_file) || die("Could not open file!");

when i make it say open(BOT, $data_file);

nothing is shown but it showed b4 any suggestions
  
Back to top
ICQYIM  
IP Logged
 
DemonSlayer
God Member
*****
Offline


I am the face of pure
evil!

Posts: 1398
Joined: Jul 26th, 2001
Gender: Male
Re: Cgi giveing me a headach
Reply #1 - Apr 10th, 2002 at 1:02am
Print Post  
make sure that the file exists and if all else fails just stick the location into the open command instead of the variable
  
Back to top
ICQAIM  
IP Logged
 
Michael
God Member
*****
Offline


Recursion \Re*cur"sion\,
n. - See recursion.

Posts: 1003
Joined: Oct 23rd, 2001
Gender: Male
Re: Cgi giveing me a headach
Reply #2 - Apr 10th, 2002 at 1:18am
Print Post  
Well, you'd best print the HTTP headers (content-type: text/html) before you do the open, because if the open fails, then the program will end and attempt to print "Could not open file!" but since no headers have been printed out, it won't know that it's giving out text/html. If you take out the die, it won't try to print anything, so no worries.

Do you understand?
  

~ Michael ~
-------------
The MikeCam
A truly wise man never plays leapfrog with a unicorn.
Back to top
IP Logged
 
Dave Baughman
God Member
*****
Offline


I want my MTV

Posts: 2039
Location: Murfreesboro
Joined: May 18th, 2001
Gender: Male
Re: Cgi giveing me a headach
Reply #3 - Apr 10th, 2002 at 1:31am
Print Post  
Is the file data.txt located in the same directory as the script? Also, do
open(BOT, "$data_file")
It may not be parsing the variable because you don't have double quotes around it. And if you want to be specific, do
open(BOT, "<$data_file")
The < is implied if you don't specify it... it just means open for reading. But you can stick it in there anyway just in case. If the file doesn't exist in the same directory as the script, though, it will spit out the error.

- Dave
  

I'm not sure if it's ignorance or apathy, but I don't know and I don't care.
Back to top
WWW  
IP Logged
 
Michael
God Member
*****
Offline


Recursion \Re*cur"sion\,
n. - See recursion.

Posts: 1003
Joined: Oct 23rd, 2001
Gender: Male
Re: Cgi giveing me a headach
Reply #4 - Apr 10th, 2002 at 1:51am
Print Post  
It really should work without the double quotes, I believe. Which part of the error were you worrying about, Matt? The part about not finding the file or the part about the HTTP headers? Or both?
  

~ Michael ~
-------------
The MikeCam
A truly wise man never plays leapfrog with a unicorn.
Back to top
IP Logged
 
throesch
God Member
*****
Offline


I will own you all. will
you be on the good list?

Posts: 561
Location: Arab
Joined: Nov 9th, 2001
Gender: Male
Re: Cgi giveing me a headach
Reply #5 - Apr 10th, 2002 at 1:52am
Print Post  
ok i tried every thing yall suggested and yes the file is there.
  
Back to top
ICQYIM  
IP Logged
 
throesch
God Member
*****
Offline


I will own you all. will
you be on the good list?

Posts: 561
Location: Arab
Joined: Nov 9th, 2001
Gender: Male
Re: Cgi giveing me a headach
Reply #6 - Apr 10th, 2002 at 1:55am
Print Post  
ok after trying every thing it dont work.

i beleave that the server is at fault b/c it worked b4 they crashed
  
Back to top
ICQYIM  
IP Logged
 
throesch
God Member
*****
Offline


I will own you all. will
you be on the good list?

Posts: 561
Location: Arab
Joined: Nov 9th, 2001
Gender: Male
Re: Cgi giveing me a headach
Reply #7 - Apr 10th, 2002 at 6:40pm
Print Post  
ok now that i fixed that darn problem i have a question how would i add a time loop. what i mean is after a sertain amount of time passes would i make it refresh. in case new info was added.
  
Back to top
ICQYIM  
IP Logged
 
Michael
God Member
*****
Offline


Recursion \Re*cur"sion\,
n. - See recursion.

Posts: 1003
Joined: Oct 23rd, 2001
Gender: Male
Re: Cgi giveing me a headach
Reply #8 - Apr 10th, 2002 at 6:56pm
Print Post  
Well, if it's outputting HTML, just put in a meta refresh.
Code
Select All
<meta http-equiv="Refresh" Content="15; URL=http://www.blah.com"> 



Change 15 to the number of seconds between refreshes.
  

~ Michael ~
-------------
The MikeCam
A truly wise man never plays leapfrog with a unicorn.
Back to top
IP Logged
 
throesch
God Member
*****
Offline


I will own you all. will
you be on the good list?

Posts: 561
Location: Arab
Joined: Nov 9th, 2001
Gender: Male
Re: Cgi giveing me a headach
Reply #9 - Apr 10th, 2002 at 8:44pm
Print Post  
well ive tried that but when i add the meta code to the cgi it kills the cgi

also do i have to have it in the <head> tag
  
Back to top
ICQYIM  
IP Logged
 
Christer Alexander
God Member
*****
Offline


Make my day...

Posts: 3443
Location: Lethbridge
Joined: Feb 10th, 2002
Gender: Male
Re: Cgi giveing me a headach
Reply #10 - Apr 12th, 2002 at 10:24am
Print Post  
yes, all <meta> tags must be inside a <head>....</head> tag.....
  

Code
Select All
unless(0) { stab("LoonyPandora"); next; } 

Back to top
IP Logged
 
Michael
God Member
*****
Offline


Recursion \Re*cur"sion\,
n. - See recursion.

Posts: 1003
Joined: Oct 23rd, 2001
Gender: Male
Re: Cgi giveing me a headach
Reply #11 - Apr 12th, 2002 at 9:18pm
Print Post  
Post the spot where you put in the meta tag, there's no reason for it to be "killing" the script.
  

~ Michael ~
-------------
The MikeCam
A truly wise man never plays leapfrog with a unicorn.
Back to top
IP Logged
 
throesch
God Member
*****
Offline


I will own you all. will
you be on the good list?

Posts: 561
Location: Arab
Joined: Nov 9th, 2001
Gender: Male
Re: Cgi giveing me a headach
Reply #12 - Apr 15th, 2002 at 4:11am
Print Post  
darn im sorry for all this i found out my host is messing with perl and it is really messed up
  
Back to top
ICQYIM  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint