home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / pascal / 7877 < prev    next >
Encoding:
Text File  |  1993-01-05  |  3.2 KB  |  76 lines

  1. Newsgroups: comp.lang.pascal
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!rpi!usc!cs.utexas.edu!torn!mcshub!csx.cciw.ca!u055
  3. From: u055@csx.cciw.ca (James Sprenger)
  4. Subject: Re: File locking question
  5. Organization: Canada Centre for Inland Waters
  6. Date: Tue, 5 Jan 1993 22:03:46 GMT
  7. Message-ID: <1993Jan5.220346.24647@csx.cciw.ca>
  8. References: <Hendrik.Klompmaker.31.726184187@beheer.zod.wau.nl> <ppollet.118.726255594@cismibm.univ-lyon1.fr>
  9. Lines: 65
  10.  
  11. In article <ppollet.118.726255594@cismibm.univ-lyon1.fr> ppollet@cismibm.univ-lyon1.fr (Patrick POLLET) writes:
  12. >In article <Hendrik.Klompmaker.31.726184187@beheer.zod.wau.nl> Hendrik.Klompmaker@beheer.zod.wau.nl (Hendrik Klompmaker) writes:
  13. >>From: Hendrik.Klompmaker@beheer.zod.wau.nl (Hendrik Klompmaker)
  14. >>Subject: File locking question
  15. >>Date: Mon, 4 Jan 1993 21:49:47 GMT
  16. >
  17. >>Hy,
  18. >
  19. >>This might not be the correct folder to put this question but I thought 
  20. >>there might be a TP solution.
  21. >>I have to keep a log file a everyone who logs in to my network. A bacth file 
  22. >>is used to write to that log file by simple redirection:
  23. >>username >>logfile.dat
  24. >>which writes the username, time and date to the log file.
  25. >>A problem arrises when 2 people log in at the same time. Right: the log file 
  26. >>is locked by one of them and the other one gets a A-R-I error (abort,re...)
  27. >>Is there a simple (and fast and small) method to detect if a file is locked 
  28. >>or not. (since username is a TP program it would sure be possible to do the 
  29. >>checking there (how ??) but maybe it would even be possible to do that at 
  30. >>dos/batch level. 
  31. >>Any hints ??
  32. >
  33. >>Bye
  34. >
  35. >>Hendrik
  36. >
  37. >>===============================================================================
  38. >>|******** Wageningen Agricultural University. Animal Production Group ********|
  39. >>-------------------------------------------------------------------------------
  40. >>Hendrik Klompmaker              Internet : Hendrik.Klompmaker@Beheer.Zod.Wau.Nl
  41. >>System Manager                  Bitnet   : KLOMPMAKER@HWALHW50.BITNET
  42. >>Phone : +31 (0)8370-83934       Fax      : +31 (0)8370-83962
  43. >>Snail : Marijkeweg 40, 6709 PG  WAGENINGEN, The Netherlands
  44. >>===============================================================================
  45. >
  46. >        If you want your files to be "SHAREABLE" you should fiddle with the 
  47. >FileMode public variable of TurboPascal BEFORE doing any Reset,Rewrite,
  48. >Close (and possibly Append :I did not tried that one yet )
  49.  
  50. I don't think this will work 'cause the file that is accessed is
  51. redirected from the command line, and not initialized from the TP prog. 
  52. Even if you did open the file from the TP program, I think you'll run into
  53. problems when two people try to write to the file simultaneously (spelling?)
  54. Any how, if you are using a Novell NetWare network, its probably best to
  55. use semaphores...these netware function are faaaast and you don't have to
  56. write your own lowlevel IO routines. 
  57.  
  58. >
  59. > So my guess  is that your program username should:
  60. >
  61. >  -be compiled with $I-  (no stop on runtime error)
  62. >
  63. >  -Repeat
  64. >     -try to open the file in mode $11 (Write and deny ALL)
  65. >  -Until (IoResult=0)  (* nobody else has locked it *)
  66. >
  67.  
  68. I tried a similar routine with an app I was writing and never quite got it to
  69. work.  Maybe I should look at it again....
  70.  
  71. Cheers.
  72.  
  73. James Sprenger : u055@csx.cciw.ca
  74.  
  75.  
  76.