Re: Appending a unique line to a file



Steve Swift wrote:
[snip]
There's obviously more to the code above that I can understand. I'm relatively new to anything with a "~" in it.
What's the mechanism that stops two concurrent threads (our server has four processors) getting to the "append" bit and both appending?.
On OS/2 (our previous server) this was simple, as you couldn't open a file for output on more than one thread; OS/2 caused the second to fail.

So this is running on the same machine? Apache generating threads for multiple clients or some similar server?

Use queue to pass from multiple clients to another rexx thread running on the same machine that keeps the writing in one thread.

(Example attached)
--
Brandon Cherry
::routine loadIndexes public
use arg fn
dates = .set~new()
fs = .stream~new(fn)~~open('shareread')
do until fs~lines() == 0
parse value fs~linein with yyyymm .
dates~put(yyyymm)
end
fs~~close()
return datesfn = 'example.txt'
dates = loadIndexes(fn)
call rxqueue 'create', 'myQ'
call rxqueue 'set', 'myQ'

fs = .stream~new(fn)
say 'Press Q to end.'
do forever
if chars() \== 0 then do
parse upper value sysGetKey('noecho') with key
if key == 'Q' then exit
end
do while queued() \== 0
pull userid
say 'Received:' userid
currentDate = substr(date('s'), 1, 6)
if \dates~hasIndex(currentDate) then do
say currentDate userid
dates~put(currentDate)
fs~~open('shareread write append')~~lineout(currentDate userid)~~close()
end
end
call syssleep 0.01
end

::requires 'include.rex'dates = loadIndexes('example.txt')
call rxqueue 'set', 'myQ'

say 'Type Q to end.'
do forever
call charout , 'Enter userid: '
parse upper linein userid
push userid
if userid~left(1, 1) = 'Q' then exit
end

::requires 'include.rex'

Relevant Pages

  • Re: schedule job - login in dynamic sql
    ... If the user created the stored proc without ... You have a userid as the login on the server. ... usually the Agent userid is a member of the sysadmin, or at least of dbo), ...
    (microsoft.public.sqlserver.programming)
  • Re: WSS: Finding My Sites through SQL
    ... sites on a diferent server than the WSS server. ... foreach (XmlNode node in AllSites) ... and I came up with this SQL: ... Select @userId = tp_ID from UserInfo where tp_login like 'DOMAIN ...
    (microsoft.public.sharepoint.windowsservices)
  • WSS: Finding My Sites through SQL
    ... sites on a diferent server than the WSS server. ... foreach (XmlNode node in AllSites) ... and I came up with this SQL: ... Select @userId = tp_ID from UserInfo where tp_login like 'DOMAIN ...
    (microsoft.public.sharepoint.windowsservices)
  • Re: login info from ie screen
    ... windows userid from the client machine, but it displays another userid that ... As if there is miscommunication between client and windows 2003 server. ... >> intranet userid that is different than her actual windows userid. ...
    (microsoft.public.frontpage.client)