Sponsored Content
Full Discussion: File read/ write operation
Operating Systems Linux File read/ write operation Post 302425573 by Corona688 on Friday 28th of May 2010 01:21:27 PM
Old 05-28-2010
Quote:
Originally Posted by xs2punit
I do not want to lock anything.
Clearly. You should, though. Otherwise you're going to hit all the pitfalls we've been telling you about repeatedly, and all you'll be doing by doing it in AJAX instead is building your own slower, buggier, flock-over-http protocol from the ground up.
Quote:
Issue is server doesn't release the file to be read.
Doesn't release the file? What error do you get when you try to retrieve it -- does it think the file's not present at all, or give 'permission denied', etc. Either is quite odd, most UNIX systems don't do mandatory locking of open files, nor play tricks to hide files until they're complete; what system are you using?

Last edited by Corona688; 05-28-2010 at 02:32 PM..
 

10 More Discussions You Might Find Interesting

1. IP Networking

how do you get to know if the write operation was succesful.

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

read and write from a file

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

Simultaneous file read operation

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

Write/read to file descriptors

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

monitoring multipath IO for read and write operation

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

read/write,write/write lock with smbclient fails

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

Transferring file write operation to another host

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

Grab data between 2 keywords any do an array operation and write the file intact

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

File Read and Write

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

Read and write in the file

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
flock(2)							System Calls Manual							  flock(2)

NAME
flock - Applies or removes an advisory lock on an open file SYNOPSIS
#include <sys/fcntl.h> int flock( int filedes, int operation ); PARAMETERS
Specifies a file descriptor returned by a successful open() or fcntl() function, identifying the file to which the lock is to be applied or removed. Specifies one of the following constants for flock(), defined in the fcntl.h file: Apply a shared lock. Apply an exclusive lock. Do not block when locking. This value can be logically ORed with either LOCK_SH or LOCK_EX. Remove a lock. DESCRIPTION
The flock() function applies or removes an advisory lock on the file associated with the filedes file descriptor. Advisory locks allow cooperating processes to perform consistent operations on files, but do not guarantee consistency (that is, processes may still access files without using advisory locks, possibly resulting in inconsistencies). You can use the flock() function to coordinate a file's lock status on local, CFS, and NFS file systems. The locking mechanism allows two types of locks: shared locks and exclusive locks. At any time multiple shared locks may be applied to a file, but at no time are multiple exclusive, or both shared and exclusive, locks allowed simultaneously on a file. A shared lock may be upgraded to an exclusive lock, and vice versa, simply by specifying the appropriate lock type. This results in the previous lock being released and the new lock applied (possibly after other processes have gained and released the lock). Requesting a lock on an object that is already locked normally causes the caller to be blocked until the lock may be acquired. If LOCK_NB is included in operation, then this will not happen; instead, the call will fail and errno will be set to [EWOULDBLOCK]. NOTES
Locks are on files, not file descriptors. That is, file descriptors duplicated using the dup() or fork() functions do not result in multi- ple instances of a lock, but rather multiple references to a single lock. If a process holding a lock on a file forks and the child explicitly unlocks the file, the parent will lose its lock. Processes blocked awaiting a lock may be awakened by signals. The flock() interface is not part of any UNIX standard. Therefore, if you are designing and writing applications to be portable across platforms, you should use the fcntl() file locking interface instead of flock(). RETURN VALUES
Upon successful completion, 0 (zero) is returned. Otherwise, -1 is returned and errno is set to indicate the error. ERRORS
If the flock() function fails, errno may be set to one of the following values: The file is locked and the LOCK_NB option was specified. The filedes argument is not a valid open file descriptor. A signal interrupted the flock call. The operator is not valid. The lock table is full. Too many regions are already locked. The lock is blocked by some lock from another process. Putting the calling process to sleep while waiting for that lock to become free would cause a deadlock. RELATED INFORMATION
Functions: close(2), exec(2), fcntl(2), fork(2), open(2), lockf(3) delim off flock(2)
All times are GMT -4. The time now is 04:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy