Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error reading from file

Status
Not open for further replies.

vivekm

Programmer
Oct 4, 2000
76
GB
Hi all,

Here is my script:
$data_file="wrestledata.cgi";
open(DAT, $data_file) || die("Could not open file!");
@raw_data=<DAT>;
close(DAT);

print &quot;Content-type: text/html\n\n&quot;;
print &quot;<HTML><BODY>&quot;;
print &quot;<HEAD>&quot;;
print &quot;<TITLE>Perl Variable Test</TITLE>&quot;;
print &quot;</HEAD>&quot;;

foreach $wrestler (@raw_data)
{
chop($wrestler);
($w_name,$crowd_re,$fav_move)=split(/\|/,$wrestler);
print &quot;When $w_name is in the ring, the crowd might $crowd_re when the $fav_move is used.\n&quot;;
print &quot;<BR>\n&quot;;
}

print &quot;</BODY></HTML>&quot;;

----------------
When I run this using command prompt, I get the following:
Content-type: text/html

<HTML><BODY><HEAD><TITLE>Perl Variable Test</TITLE></HEAD>When The Rock is in th
e ring, the crowd might Cheer when the Rock Bottom is used.
<BR>
When Triple H is in the ring, the crowd might Boo when the Pedigree is used.
<BR>
When Stone Cold is in the ring, the crowd might Cheer when the Stone Cold Stunne
r is used.
<BR>
</BODY></HTML>

------------------
Unfortunately, when I run this from within Windows IE (Win2K using IIS), I get CGI Error:
&quot;Could not open file! at c:\inetpub\ line 2.&quot;

-----------------------
Pls advise urgently.

Regards,
Vivek
 
Change your statement

die(&quot;Could not open file!&quot;);

to

die(&quot;Could not open file ($data_file)\n$!\n&quot;);

That will give you a bit more information.
Mike

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

It's like this; even samurai have teddy bears, and even teddy bears get drunk.
 
I get the message:

Could not open file!(wrestledata.cgi)
No such file or directory

The web address is: (which is the location where wrestledata.cgi is located). Do I have to change permissions on IIS to run CGI scripts?

Regards,
Vivek
 
Sorry Vivek, I don't know anything about IIS or CGI - you do have a pointer to the problem though. Maybe you need to specify a complete path to the file? Mike

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

It's like this; even samurai have teddy bears, and even teddy bears get drunk.
 

Thanks Mike - that worked. Cannot imagine why the whole path has to be given though.

Cheers,
Vivek
 
It's probably just that IIS runs with its &quot;current directory&quot; as /, or something..... Mike

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

It's like this; even samurai have teddy bears, and even teddy bears get drunk.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top