create text file with perl on windows 2000 server

Ken Elliott's picture

They have: 358 posts

Joined: Jun 1999

I'm used to working on *nix servers and haven't really tested any of my scripts for windows. But I've got a client who is already payed up on a windows server and I am trying to migrate some of my services over to her new website, but I am finding that it appears like the windows 2000 server will not let my simple perl script create a flat text file. Is it not possible, or am I doing it wrong? I am simply trying to write to a file that isn't there.. in *nix it will automatically create the file and then write to it.

Thanks for any help.
webG

Pimpin like a pimp with an electrofied pimpin machine!

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

Do you get any errors?

They have: 447 posts

Joined: Oct 1999

open (OUTFILE, '>./outfile.txt') or die("Error opening file: $!");
print OUTFILE 'testin';
close OUTFILE;
'

works fine.

Ken Elliott's picture

They have: 358 posts

Joined: Jun 1999

D:\inetpub\wwwroot\014143\sc3eb59g\cgi-bin\test.cgi' script produced no output

#!/usr/bin/perl

open (OUTFILE, '>./outfile.txt') or die("Error opening file: $!");
print OUTFILE 'testin';
close OUTFILE;

print "Content-type:text/plain\n\n";
print "Created";
'

if I comment out the outfile, it works fine of course. I'm trying to track down the error log on this server, I hate windows servers :flame:

thanks
webG

Pimpin like a pimp with an electrofied pimpin machine!

They have: 447 posts

Joined: Oct 1999

hmm, works for me on win2k pro from both the command line and through Apache. Maybe it's an IIS permissions issue ...

They have: 601 posts

Joined: Nov 2001

I *think* your IIS isn't properly configured to handle CGI.

Is Perl setup correctly on the server? There are a few example test scripts (like, hello world!) included with all Perl distributions in /examples. Try those out.

Is your path to Perl correct in the shebang line and has an env. variable been set in Windows to instruct IIS to open .pl or .cgi with Perl?

- wil

Ken Elliott's picture

They have: 358 posts

Joined: Jun 1999

all of the scripts run fine so long as they don't try to create a file. I guess it was a permissions thing, I got server support to give me write access to a folder. I remember from my readings a while back something about windows servers not having permissions. I know that I couldn't change them through an ftp client, that was enough proof for me.

So I guess there is no way to change permissions or give myself write access to a folder I create with an ftp client?

ken

Pimpin like a pimp with an electrofied pimpin machine!

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.