mutual exclusion write access

Scott "The Pseudo-Hacker" Neugroschl abcscnge at csuna.csun.edu
Mon Jul 31 08:49:34 AEST 1989


In article <1505 at laura.UUCP> bause at exunido.UUCP (Falko Bause) writes:
]
]I want to allow only mutually exclusive write-accesses to a certain file.
]I've searched through the manual pages and have only found commands
]like lockf. But these commands only allow to establish a mutual
]exlusive access for sub-processes of some process.
]
]Let's explain, what I want, through an example:
]
]There is a file (e.g.) named   text. I want that the following commands
]getting only exclusive write access:
]	du > text
]	ls -R > text
]	myprog > text        etc.
]

This is kind of kludgy, but how about:

	( chmod 600 text ; du ) > text

This allows "text" to be writable only by you.  If you don't want yourself
to overwrite your own data:

	( chmod 400 text ; du ) > text

or, if you're REALLY paranoid:

	( chmod 000 text ; du ) > text

The shell creates "text" before executing the subshell commands, thus
the file is ALREADY open, so there is no problem with changing the modes.
Of course, the last is kind of useless, cuz you have to chmod text to some
readable mode.


-- 
Scott "The Pseudo-Hacker" Neugroschl
UUCP:  ...!sm.unisys.com!csun!csuna.csun.edu!abcscnge
-- Beat me, Whip me, make me code in Ada
-- Disclaimers?  We don't need no stinking disclaimers!!!



More information about the Comp.unix.questions mailing list