How to Understand file writing in Progress in UNIX?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to Understand file writing in Progress in UNIX?
# 1  
Old 06-04-2015
How to Understand file writing in Progress in UNIX?

Hi All,

I have a requirement, where i have to pool file A data to file B continuously and need to process the data in the file B.

Since the data need to be processed only once so i have to truncate the data in file A after every pool. So that on the next pooling i can get the fresh data and there will be no duplication.

Issue: In case when i am truncating the data of FileA if some date getting written on the FileA then it will also get truncated. So i am looking for a process where i can capture that the file is getting written or some way by which i can lock the file for truncation.

My piece of sample code:

Code:
n=1
while ($n=1)
do
    Input_File= FileA.txt
    Copy_File= FileB.txt
    cp $Input_File $Copy_File
    >$Input_File 
    #Post above steps i process the data in FileB.txt with my filthy code
done

Thanks for you Suggestion in Advance
Moderator's Comments:
Mod Comment Please use code tags

Last edited by jim mcnamara; 06-04-2015 at 09:52 AM..
# 2  
Old 06-04-2015
What shell are you using? There are some errors in your code to start with.
# 3  
Old 06-04-2015
Does a writer process keep fileA open or does its inode need to remain constant? If not, why don't you just mv the file?
# 4  
Old 06-08-2015
Maybe it is as simple as
Code:
tail -f file.a >fileb

 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

Writing a UNIX shell script to call a C function and redirecting data to a .txt file

Hi, I am complete new to C programming and shell scripting. I just wrote a simple C code to calculate integral using trapezoid rule. I am prompting user to pass me No. of equally spaced points , N , upper and lower limit. My code looks as follows so far: #include<stdio.h> #include<string.h>... (2 Replies)
Discussion started by: bjhjh
2 Replies

2. Red Hat

How to Understand the UNIX Time Format?

How to understand the unix time format as here i have pasted this is a unix time 1402565420 and its 3:00 PM here but its give this Output as long number How can i make it to understand format as i have 3:00 PM Normal time format <----3:00PM = 1402565420----> Unix Time Will Any one Explain to... (4 Replies)
Discussion started by: babinlonston
4 Replies

3. Shell Programming and Scripting

i writing a unix script but i want to out put a file and append on it.

i have an existing script that is used to send an e-mail containing the alrams that appear on the server. But i need to create a daily log file containing all the alarms that was send that day. i tired to add at the and of the script a command, echo command but for some reason the file was... (1 Reply)
Discussion started by: ashraf_victory
1 Replies

4. Shell Programming and Scripting

Understand a old unix shell script

Hi All, I have a unix old script i but i am not able to understand the few commands in it and what it does. below is the script. if ; then for F in $(find $DIR/. ! -name . -prune -name "DP_*.dat") do IN=${F##/*/} OUT='ORD'$(echo $IN | cut -c7-) exec.ksh $IN... (2 Replies)
Discussion started by: kam786sim
2 Replies

5. UNIX for Dummies Questions & Answers

trying to understand rationale of unix stream i/o concept

I am an entry level programmer with no formal training in computer science. I am trying to enhance my conceptual knowledge about operating systems in general. I have been using the C programming language on Linux systems for some time and have used the traditional unix stream I/O APIs. The... (1 Reply)
Discussion started by: kaychau
1 Replies

6. Shell Programming and Scripting

Progress Bar in Perl for UNIX

Hi Programmers, I just wrote a small script to print the percent complete. This maybe useful for someone! #!/usr/local/bin/perl # Total from which percentage will be calculated $cnt = 16; $|=1; for($i=0;$i<$cnt;$i++) { # Calculate Percentage $percent = ($i/$cnt)*100; (13 Replies)
Discussion started by: hifake
13 Replies

7. UNIX for Advanced & Expert Users

don't understand the unix script

if {"$my_ext_type" = MAIN]; then cd $v_sc_dir Filex.SH $v_so_dir\/$v_fr_file Can somebody tell me what does this suggest. I am pretty new to unix and I am getting confused. What i understood from here is If we have a file extension name as MAIN which we have then we change the directory to... (1 Reply)
Discussion started by: pochaman
1 Replies

8. UNIX and Linux Applications

UNIX memory problems w/Progress DB

We are currently running HP-UX 11 as our database server. The database is Progress version 9.1C. As of late, some of our batch processes that run on the UNIX db server are erroring out because of what appear to be memory issues(at least according to Progress). The db error messages indicate... (0 Replies)
Discussion started by: eddiej
0 Replies

9. UNIX for Advanced & Expert Users

writing database tables into a file in unix

I want to collect the database tables(Ex: Emp,Sal,Bonus...etc) in a file & give this file at the command prompt, when prompted for the tables list at command prompt. How can i do that ? Ex:- Import jason/jason1 tables=emp,sal,bonus log=j1.log i want to change this into Ex:- Import... (3 Replies)
Discussion started by: dreams5617
3 Replies
Login or Register to Ask a Question