Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

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...

Comment on Appending to Files on NT?
Download Code
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

      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!

      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")
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.

    HTH

    grep
    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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://140544]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2014-07-25 23:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (175 votes), past polls