Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Appending to Files on NT?

by mr_dont (Beadle)
on Jan 22, 2002 at 04:23 UTC ( #140544=perlquestion: print w/replies, xml ) Need Help??
mr_dont has asked for the wisdom of the Perl Monks concerning the following question:

Fellow Monks,

I am stumped by the behaviour of file functions on a windows NT Server I am using. Basically, I can open a file for reading, but I cannot append to a file. I am using the absolute path in my open statement. I have also tried to use the binmode() function, to no avail. Thus my code looks something like:

$somestuff = "This is a new line for my data file"; $filename = "d:/foo/bar/myfile.dat"; open (DATA,">>$filename") || die("Cannot Open Database File"); binmode (DATA); print DATA $somestuff; close DATA;

This code dies and gives me my "Cannot open database file" error

I also tried to use the path d:\\foo\\bar\\myfile.dat

Does anymonk know what is the problem? Is it a permissions issue? Unfortunately, I am not the administrator of this server!

Thanks Monks...

Replies are listed 'Best First'.
Re: Appending to Files on NT?
by wog (Curate) on Jan 22, 2002 at 04:52 UTC

    You can probably tell what the problem is by including the special variable $! in the error message.

    update: added link

      Excellent idea. In this particular case, the value of $^E might also be helpful. I suspect that the file is open by a program that isn't sharing write access. See the Win32API::File documentation of the $svShare argument to createFile() for more information on this.

              - tye (but my friends call me "Tye")

      Right wog!

      Thanks for the tip! It was a permissions problem. Hmmm... I hope I hope I can set the permissions of the file on the NT server using my linux ftp client!

Re: Appending to Files on NT?
by grep (Monsignor) on Jan 22, 2002 at 04:56 UTC
    I would check your permissions on that file. Else, if this is a CGI application you need to check the permissions of either the IIS anonymous user or the authenticated user.


    grep> cd pub
    grep> more beer
Re: Appending to Files on NT?
by Anonymous Monk on Jan 22, 2002 at 16:13 UTC
    maybe this comes from the the access permissions. try the chmod() function , it gives quite the same results that the DOS-SHELL ATTRIB function. hope this will help...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://140544]
Approved by root
[PriNet]: quick question... anyone know how to remove all the existing keys in a %hash ? i've tried several options, but when i re-use the hash, some of the "upper" keys that i don't re-use stick and i can't get them to "remove"
[atcroft]: PriNet: %hash = ();? or foreach my $k ( keys %hash ) { delete $hash{$k}; }?

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2017-06-28 02:54 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (619 votes). Check out past polls.