05-27-2010
Even if you do manage to transmit this variable to the AJAX script somehow it's going to be a very awkward solution involving lots of retries, handfuls to dozens to hundreds more HTML retrievals than really necessary, etc. This should be solved on the server end, not the client. Instead of a rube goldberg system to check if an EOF was the real EOF, just don't EOF unless you mean it when sending the file to the client!
Advisory locking, as already said, is the way to do this. The server-side script that writes the file should always keep the very last section of the file locked. When it finishes writing another block, lock it, unlock the one before, write more, lock, unlock, etc. Once it's finally done,unlock the file completely.
The server-side script that reads the file should do much the same: always lock the section before it reads it. If the writer program doesn't have data ready for it, it'll be made to wait until the writer unlocks it. So lock a section, read it, unlock it, lock the next section, read it, unlock, repeat until EOF.
The relevant function call is flock.
10 More Discussions You Might Find Interesting
1. IP Networking
how do you get to know if the write operation for writing to a socket was succesful was succesful. (3 Replies)
Discussion started by: arjunjag
3 Replies
2. Shell Programming and Scripting
I have tried to show the file name whose size is greater than 200 byte in current directory.
Please help me.
ls -l | tr -s " " " " | cut -f 5,9 -d " " >out.txt
#set -a x `cat out.txt`
i=0
`cat out.txt` | while
do
read x
echo $x
#re=200
j=0
if }" < "200" ]
then
echo $j
j=`expr $j... (2 Replies)
Discussion started by: rinku
2 Replies
3. UNIX for Dummies Questions & Answers
Hi All,
I need information on file handling in UNIX enviornment.
If in UNIX enviornment I have two process..
P1
P2
Both accessing the same file simultaneosuly(read operation)..
Suppose P1 opened the file in read mode first and started reading the file..
Then P2 opens the same file in... (5 Replies)
Discussion started by: chibob
5 Replies
4. UNIX for Dummies Questions & Answers
Is it possible to write to file descriptor 0 and read from 1 or 2? How could this be implemented? (3 Replies)
Discussion started by: machshev
3 Replies
5. Solaris
Hi Folks,
I would like to monitor multipath IO on solaris for write and read operations.
Does "sar -d" include multipath IO information along with other block devices ?
Thanks,
Faizan. (0 Replies)
Discussion started by: sifaizan
0 Replies
6. IP Networking
Hi,
We have smb client running on two of the linux boxes and smb server on another linux system. During a backup operation which uses smb, read of a file was allowed while write to the same file was going on.Also simultaneous writes to the same file were allowed.Following are the settings in the... (1 Reply)
Discussion started by: swatidas11
1 Replies
7. Shell Programming and Scripting
I have a process running on two hosts in Active/Standby mode. Process running on active machine is handling the traffic while process running on Standby machine is sitting idle.
We have a debugging mechanism in which logs are generated on local machine. When logging is enabled then process running... (1 Reply)
Discussion started by: akhilonnet
1 Replies
8. Shell Programming and Scripting
Hi Unix Gurus,
I need to grep for a block that is between a start and end keyword and then in between I need to find and replace a keyword.
for eg: I need to search between Test = 000; and Test = 000; and find K9 and replace with M9
INPUT FILE
Define {
Replace = K9;
Test =... (6 Replies)
Discussion started by: naveen@
6 Replies
9. Shell Programming and Scripting
I have got a file in following format:
AAAAAAA
BBBBBBBB
CCCCCCC
DDDDDDD
I am trying to read this file and out put it in following format:
AAAAAAA,BBBBBBB,CCCCCCC,DDDDDD
Preferred method is shell or Perl.
Any help appreciated. (11 Replies)
Discussion started by: Araoki
11 Replies
10. Shell Programming and Scripting
Hello Guys, How all are doing?
I have an issue in Unix and want help from all of you
I have a file in UNIX which it read by line by line , If at the end of line '0' is written the it should fetch that line into another file and change '0' to '1'
and If at the end of line '1' is written then it... (10 Replies)
Discussion started by: adisky123
10 Replies
LEARN ABOUT X11R4
xkblockmodifiers
XkbLockModifiers(3) XKB FUNCTIONS XkbLockModifiers(3)
NAME
XkbLockModifiers - Locks and unlocks any of the eight real keyboard modifiers
SYNOPSIS
Bool XkbLockModifiers ( display, device_spec, affect, values )
Display *display;
unsigned int device_spec;
unsigned int affect;
unsigned int values;
ARGUMENTS
display
connection to the X server
device_spec
device ID, or XkbUseCoreKbd
affect mask of real modifiers whose lock state is to change
values 1 => lock, 0 => unlock; only for modifiers selected by affect
DESCRIPTION
XkbLockModifiers sends a request to the server to lock the real modifiers selected by both affect and values and to unlock the real modi-
fiers selected by affect, but not selected by values. XkbLockModifiers does not wait for a reply from the server. It returns True if the
request was sent, and False otherwise.
The functions in this section that change the use of modifiers use a mask in the parameter affect. It is a bitwise inclusive OR of the
legal modifier masks:
Table 1 Real Modifier Masks
----------------------------
Mask
----------------------------
ShiftMask
LockMask
ControlMask
Mod1Mask
Mod2Mask
Mod3Mask
Mod4Mask
Mod5Mask
RETURN VALUES
True The XkbLockModifiers function returns True if a request is sent to the server to lock the real modifiers selected by both
affect and values and to unlock the real modifiers selected by affect, but not selected by values.
False The XkbLockModifiers function returns False if the request was not sent.
X Version 11 libX11 1.2.1 XkbLockModifiers(3)