Simultaneous file read operation


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Simultaneous file read operation
# 1  
Old 10-16-2008
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 read mode, will P2 read the file from beginning of the file, or it will start reading the file from where P1 is reading currently(becuase the file position indicator would be incremented by P1 by the time P2 opens it)..
# 2  
Old 10-16-2008
You know why I like UNIX?
You can see for yourself...
What is stopping you to connect twice to the box? (nothing)
So why not try and see what happens...
# 3  
Old 10-16-2008
Actually I am trouble shooting a problem which we are facing in our daemon process.
As described above.. Process P2 is not reading the file from the beginning..

I wandering whats the problem, since P1 and P2 are two independent process which are reading the same file..

I want to confirm my doubt, if anybody has faced such situation before.
# 4  
Old 10-16-2008
What language are you using to read the files? Can you show us the script/program?
# 5  
Old 10-16-2008
Code is in C.
The code is very huge..

But here is a very small portion of code to read the file..

if ((cnf = fopen(zl->MlConfFile, "r")) == NULL) {
zl->warn(zl, LOG_ERR, "Failed to open multilevel library config file '%s'",
zl->MlConfFile);
return -1;
}

while(!feof(cnf)) {
/* Scan first line, hopefully containing the name of a node */
if (fgets(buf, MAXSTRBUF, cnf) == NULL) {
if (!feof(cnf)) /* Get rid of warning when EOD */
zl->warn(zl, LOG_ERR,
"Failed to read from multilevel config file '%s' %s",
zl->MlConfFile, strerror(errno));
break;
}
i++;
...
...
..
...
}
# 6  
Old 10-20-2008
Can anyone help me on this?
Thax
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Simultaneous calling of url

Hello I want to call multiple sites simultaneously by xargs or parallel for example a.com/srv/1 a.com/srv/3 a.com/srv/2 a.com/srv/n That means 500 different sites will be called in a moment Then I use command I call a url at the same time. I need to call each url once, but every 500... (1 Reply)
Discussion started by: mnnn
1 Replies

2. Homework & Coursework Questions

Limit simultaneous file access

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: So my problem is: 4990 of 5000 users should be able to access a file. How can this be accomplished. 2.... (1 Reply)
Discussion started by: protiss
1 Replies

3. UNIX for Dummies Questions & Answers

Help with ls to input for simultaneous editing

I just registered today and started unix about a month ago. I'm trying to make a script where I can add commands or text to the end of files in a listing. $ echo "#text_or_command" >> #List of files from ls I can't seem to find/understand it on these fourms. Could it be done at... (4 Replies)
Discussion started by: 62583
4 Replies

4. Shell Programming and Scripting

run script simultaneous

I have 5 scripts, basicly do the same thing. Use expect and telnet to devices. First set the variables and the script as follow spawn telnet $ipaddr expect "Username:" send -- "$usuario\r" expect "Password:" send -- "$password\r" send -- "\r" send -- "\r" send -- "copy running-config... (6 Replies)
Discussion started by: robonet
6 Replies

5. Shell Programming and Scripting

Column operation : cosne and sine operation

I have a txt file with several columns and i want to peform an operation on two columns and output it to a new txt file . file.txt 900.00000 1 1 1 500.00000 500.00000 100000.000 4 4 1.45257346E-07 899.10834 ... (4 Replies)
Discussion started by: shashi792
4 Replies

6. Linux

File read/ write operation

Hi, I am creating a progress bar for file upload for which I have CGI script which copies the data and depending on certain bytes it increments the progress bar. Here, I am writing the incremented value to a file which is read by Ajax at server end. However, here I want to ask that, is it... (18 Replies)
Discussion started by: xs2punit
18 Replies

7. 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

8. UNIX for Dummies Questions & Answers

simultaneous network start

Hi! I need to start a program at several hosts in the network at the same time. Starting time difference should be no more than several milliseconds. What is the best way to do that? Thanks! (5 Replies)
Discussion started by: harjar
5 Replies

9. Shell Programming and Scripting

running simultaneous awks

Hello, I have an awk command that searches and replaces. I have multiple searches, but I do not want to do them one after the other. Is there a way in awk to run search/replace at the same time. thanks, (3 Replies)
Discussion started by: ctcuser
3 Replies

10. UNIX for Dummies Questions & Answers

Simultaneous printing

I am running AIX 4.3 and network printing setup with HP Jetdirect. I would like to be able to send the same printout to both of the network printers at the same time. They are both PCL data stream. I have tried to make this work by linking the two print que, by the results are unpredictable. Is... (1 Reply)
Discussion started by: sjk303
1 Replies
Login or Register to Ask a Question