Setting file permissions on remote server

Bob Sneidar bobs at
Fri May 21 17:22:46 EDT 2010

Hi Bob. Nice name. 

If you set the file to read only before you open it, no one will be able to write to it, even the first user. If one user opens it read/write then the second can only open it read only. The OS will prevent anything else from happening. 

One of the reasons for using something like an SQL database is they are (for the most part) multiuser. But then you have to learn SQL, and some don't want to bother. 

One strategy would be to have a try/catch statement inside a repeat loop. Be sure to put a timer on the next retry or risk having your processors go to 100% until the write occurs. It's also a good idea to have a try counter so that when it hits a maximum you can ask the user if they want to keep trying or cancel the file update. In the try/catch statement, try to open the file read/write. If you get an error, (or some other condition that indicated the command failed) you can simply delay then next repeat. And before anything else, make sure the file is available in the first place by using "there is a file" and the fully qualified path to the file. 

One downside of this approach is the risk of leaving the file open lock stranded if the user pulls the plug on his computer during a transaction. Obviously, don't open the file until the very last moment, then close it as soon as possible. Do not have any user interaction when the file is open. Not even an answer dialog reporting an error. 

I can't (read that won't) write the code for you but I'd be happy to critique it when you're done. 


On May 21, 2010, at 1:57 PM, Bob Earp wrote:

> I have an app that reads/writes from/to a data file on a remote server.  So far there's only been one user of the app, but I wish to allow a number of users to use the app in different locations, which means I have to consider the case where more than one user wants to write to the file at the same time.  
> I was thinking that setting the data file's permissions "read only" with the first user to open the file would be the easiest way to solve this, but can't seem to get that going.  Maybe there is an easier way, or more probably I'm just being a dufus here ;-)
> In any event, does anybody have some words of wisdom/guidance, or better still a sample ?
> Many thanks, Bob...
> Bob Earp - White Rock, British Columbia, Canada 		 	   		  
> _________________________________________________________________
> 30 days of prizes: Hotmail makes your day easier! Enter Now.
> use-revolution mailing list
> use-revolution at
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:

More information about the Use-livecode mailing list