Hi,
Can you give a little more information? I'm not sure why you want world to be able to execute or write to a file that is still being written?
Thanks,
Smaug.
Update: Try:
sysopen(FILEHANDLE, $filename, permissions, CHMOD);
Just another update:
Based on
reasonablekeith comments I decided to try some tests. I ran the following code:
#!/usr/bin/perl
use strict;
use Fcntl;
my $var = 1;
while ($var) {
sysopen (FILE, '/home/smaug/testing/file.txt', O_RDWR|O_EXCL|O_CRE
+AT, 0777);
printf FILE "A value of n\n";
}
close (FILE);
This, of course, opens the file and keeps it open for reading, writing and executing...... or so it would seem. However an "ls -l" shows the following:
-rwxr-xr-x 1 root root 13 2006-11-21 11:55 file.txt
In short, sysopen calls the underlying operating system's open function. On my OS (Ubuntu Linux) the OS prevents writing to files that are already open for writing, so it seems that although it is still executable (why oh why!!) it is not writable.
(The same is shown by trying to open the same file twice using "vi".)
Again, looks can be deceiving... Trying to run the file while it is written shows:
bash: ./file.txt: Text file busy
Perhaps there are other OS's out there that allow this, but for now - I'm going with the "Cannot be done" answer.
Thanks for pricking my curiosity
reasonablekeith.