Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to Understand file writing in Progress in UNIX? Post 302945878 by mayank2211 on Thursday 4th of June 2015 07:10:03 AM
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..
 

9 More Discussions You Might Find Interesting

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

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

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

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

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

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

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

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

9. 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
TRUNCATE(2)						      BSD System Calls Manual						       TRUNCATE(2)

NAME
truncate, ftruncate -- truncate a file to a specified length LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <unistd.h> int truncate(const char *path, off_t length); int ftruncate(int fd, off_t length); DESCRIPTION
truncate() causes the file named by path or referenced by fd to have a size of length bytes. If the file previously was larger than this size, the extra data is discarded. If it was previously shorter than length, its size is increased to the specified value and the extended area appears as if it were zero-filled. With ftruncate(), the file must be open for writing; for truncate(), the process must have write permissions for the file. RETURN VALUES
A value of 0 is returned if the call succeeds. If the call fails a -1 is returned, and the global variable errno specifies the error. ERRORS
Error return codes common to truncate() and ftruncate() are: [EISDIR] The named file is a directory. [EROFS] The named file resides on a read-only file system. [ETXTBSY] The file is a pure procedure (shared text) file that is being executed. [EIO] An I/O error occurred updating the inode. [ENOSPC] There was no space in the filesystem to complete the operation. Error codes specific to truncate() are: [ENOTDIR] A component of the path prefix is not a directory. [ENAMETOOLONG] A component of a pathname exceeded {NAME_MAX} characters, or an entire path name exceeded {PATH_MAX} characters. [ENOENT] The named file does not exist. [EACCES] Search permission is denied for a component of the path prefix, or the named file is not writable by the user. [ELOOP] Too many symbolic links were encountered in translating the pathname. [EFAULT] path points outside the process's allocated address space. Error codes specific to ftruncate() are: [EBADF] The fd is not a valid descriptor. [EINVAL] The fd references a socket, not a file, or the fd is not open for writing. SEE ALSO
open(2) STANDARDS
Use of truncate() to extend a file is an IEEE Std 1003.1-2004 (``POSIX.1'') extension, and is thus not portable. Files can be extended in a portable way seeking (using lseek(2)) to the required size and writing a single character with write(2). HISTORY
The truncate() and ftruncate() function calls appeared in 4.2BSD. BUGS
These calls should be generalized to allow ranges of bytes in a file to be discarded. BSD
March 16, 2008 BSD
All times are GMT -4. The time now is 09:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy