Forum Moderators: coopster & phranque

Message Too Old, No Replies

Can't open, write or read files with Perl, IIS 6

         

JapanBlues

7:34 am on Mar 25, 2004 (gmt 0)

10+ Year Member



Hi All,

This has got me pulling my hair out so any help would be much appreciated.

I have just set up a new website with a new ISP. I have tested CGI using .pl .cgi extensions and all works fine when just creating some output for the browser. I have also tested SSI and that works ok too. I was told by my ISP that all my files outside the cgi-bin have all permissions by default so I can write to them. Obviously I want to be able to read write blah blah to files but I can't!

When I attempt to do any of that I get this: Http Status Code = 502 (Bad Gateway)in my browser.

I have tested the code on a local web server and it is fine, no problems or errors with the script. Just cant get the bloody thing to open, write or read any kind of data file. For example: (I've made the code asd simple as possible)

$file = "../data/ssitest";

open(TEST, ">>$file") ¦¦ die "can't open file because: $!";
print TEST "test baby\n";
close(TEST);

print "Content-Type: text/html\n\n";

open(TEST, $file) ¦¦ die "can't open file because: $!";
while ($line = <TEST>){
print "<br>$line";
}
close(TEST);

print "<br><br>$file";
print "<H3>End of Script</H3>\n";

Just bombs out. But the cgi functionality is there because I get output to the browser via a script.

Ive asked the ISP if it would be a problem with the internet user permissions in IIS but they are adament it's nothing to do with them.

Hissingsid

8:57 am on Mar 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi,

I would ignore what your ISP is saying and take control of permissions yourself. I had a similar problem and solved it by setting permissions as the file was created following some advice on Perlmonks.

Read up on "sysopen" to open filehandles with permissions and "umask" to adjust those permissions. Not sure exactly how this works on IIS but its worth a try. Also you need to make sure that the directory has write permissions or your file will not be written.

There's a recipe in the Perl Cookbook on this subject here [iis1.cps.unizar.es ]

I hope that this helps.

Best wishes

Sid

JapanBlues

12:31 am on Mar 27, 2004 (gmt 0)

10+ Year Member



Well the ISP says the permissions are set correctly for writing to the directory but I'm not convinced. Without asking the ISP is there any way I can prove or disprove that?

Hissingsid

7:59 am on Mar 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi,

I don't know enough about Windows to help further. There's an article on the subject here

[support.microsoft.com ]

If I had this problem on a Unix server I'd just change the permissions using my ftp client but I don't know how you do that on a Windows server.

Best wishes

Phil

JapanBlues

1:58 pm on Mar 28, 2004 (gmt 0)

10+ Year Member



The permissions work completely different to that of a unix server. You can't change them via FTP. Anyway thanks for the responses.

Hissingsid

2:21 pm on Mar 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could always move to a Unix server and solve all of your porblems. There are far more folks who are willing and able to help with Perl on Apache for example.

Also all (ok almost all) of the examples and tutorials you will find on-line and in books are based on Unix servers. So unless you really know your IIS platform you fall into all sorts of traps porting example scripts over.

I remember having one hell of a job trying to get a form to send an email on a Windows server. And then when I got it working the server kept getting attacked (along with millions of others) by anti Microsoft cyber terrorists. I moved after one such attack when the ISP took a week to install a new security patch.

Best wishes

Sid