Link to home
Start Free TrialLog in
Avatar of kudak
kudak

asked on

open file problem

hi experts!
i have a script that can read a text file. this script runs perfectly when i user free server(virtualave). but when i try to rent a server from my country, it seems that the problem occurs. the server runs in NT. Below is part of the script.

sub open_file {

  local ($filevar, $filemode, $filename) = @_;
 
  open ($filevar,$filemode . $filename) ||
     die ("Can't open $filename");
}

above is the sub to  open the file.

 &open_file("FILE1","",$filename);

and this is the program that runs that function.

the problem is, when i run it, errors appear.the error is:

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

cannot return text file(test.txt) at the following line..
open ($filevar,$filemode . $filename) ||
die ("Can't open $filename");


but this program runs smoothly when i try with virtualave.
hope someone can help.
Avatar of guadalupe
guadalupe

Try this a see what it tells you:


   
  open ($filevar,$filemode . $filename) ||
     (print ("Content-type: text-plain\n\nError codes: $! - $?") && exit);


Also check and see if the file you are trying to open  has the necessary permissions.
 
Avatar of kudak

ASKER

ok guadalupe, i've tried yours and this problem occurs.
first, it prompts me to download the perl file.
second wehen i open that perl file, this wording appears:
Error codes: No such file or directory - 0
Avatar of kudak

ASKER

i've chmoded the perl file and my text file to 755.
Try putting this line in the beginning of your original code. (the one which works on the other server) :

print "Content-type: text/html","\n\n";
ASKER CERTIFIED SOLUTION
Avatar of guadalupe
guadalupe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial