Forum Moderators: coopster & phranque

Message Too Old, No Replies

Having trouble writing to file in different directory

         

dreaming of nascar

2:08 am on Aug 3, 2003 (gmt 0)

10+ Year Member



For some reason I am having trouble writing to a file that is in another directory. This is a code snippet:
open (FILE, ">../Test.txt");
print FILE "This text is now replaced in a DIFFERENT directory!";
close (FILE);

I cannot get this to work!

Yes, I do want the information in the file currently (before this is run) to be erased (that is why I have '>' instead of '>>'). I have made sure that directory and file are writable. I hope that someone can help me out with this.
Also, when I put "¦¦ die '...';" after the open file statement my script will not run.

Any help with these siuations would be greatly appreciated. Thanks in advance!

D O N

mack

2:33 am on Aug 3, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Does it work with "fopen"?

Bit of a long shot ;-)

Mack.

dreaming of nascar

2:39 am on Aug 3, 2003 (gmt 0)

10+ Year Member



I tried that and it does not seem to do the trick.

amoore

2:42 am on Aug 3, 2003 (gmt 0)

10+ Year Member



The user that your webserver runs as probably doesn't have permissions to write to that other directory. You probably ought to "chown" it to that user.

Also, you can use "perl -c" to discover syntax errors like your problem with "die".