Sponsored Content
Top Forums Shell Programming and Scripting How do I know the file is arrived? Post 302482299 by rbatte1 on Tuesday 21st of December 2010 07:56:08 AM
Old 12-21-2010
If the file is quite small, then you probably won't have to worry about a follow up file to flag completion, so using the -f flag for a test should suffice:-
Code:
while [ ! -f $file ]
do
   echo "`date`: File has not arrived"
   sleep 5
done

If the file is larger, you need to confirm that the whole file has arrived, consider using the fuser command to look at what has the file open:-
Code:
while [ ! -f $file ]
do
   echo "`date`: File has not arrived"
   sleep 5
done
while [ `fuser $file 2>/dev/null | wc -c` -gt 0 ]
do
   echo "`date`: File is arriving"
   sleep 5
done
echo "`date`: File has arrived.  Processing will continue."

The condition for the while loop ask for the processes accessing the file. The standard error is usually the file name, so this is ditched to /dev/null. We then count the bytes returned, so if there is anything there, a process has the file open. If it is zero, then there are no processes working on the file.



I hope that this helps, but please write back if I have missed the point.


Another thought:-
If fuser fails, because of too many processes in total on the machine (we have this problem) there is an open source tool called lsof that can still run. Command required would be:
Code:
lsof +ff $file
... which gives no output at all for a closed file, so you get the answer zero for a closed file or not-zero for an open file.


Robin
Liverpool/Blackburn
UK

Last edited by rbatte1; 12-21-2010 at 09:06 AM.. Reason: Another thought
 

4 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to check the file is arrived

Hi I am doing a perl script . I wanted to check if the files have arrived in the target location for current date. the files format will be some thing like this . So for 13-sep-2012 the file will be like this. feedmgr.usfed.t_bills_20120912_20120913173232... (1 Reply)
Discussion started by: ptappeta
1 Replies

2. Shell Programming and Scripting

Match list of strings in File A and compare with File B, C and write to a output file in CSV format

Hi Friends, I'm a great fan of this forum... it has helped me tone my skills in shell scripting. I have a challenge here, which I'm sure you guys would help me in achieving... File A has a list of job ids and I need to compare this with the File B (*.log) and File C (extend *.log) and copy... (6 Replies)
Discussion started by: asnandhakumar
6 Replies

3. Shell Programming and Scripting

Compare 2 text file with 1 column in each file and write mismatch data to 3rd file

Hi, I need to compare 2 text files with around 60000 rows and 1 column. I need to compare these and write the mismatch data to 3rd file. File1 - file2 = file3 wc -l file1.txt 58112 wc -l file2.txt 55260 head -5 file1.txt 101214200123 101214700300 101250030067 101214100500... (10 Replies)
Discussion started by: Divya Nochiyil
10 Replies

4. Shell Programming and Scripting

Shell script (sh file) logic to compare contents of one file with another file and output to file

Shell script logic Hi I have 2 input files like with file 1 content as (file1) "BRGTEST-242" a.txt "BRGTEST-240" a.txt "BRGTEST-219" e.txt File 2 contents as fle(2) "BRGTEST-244" a.txt "BRGTEST-244" b.txt "BRGTEST-231" c.txt "BRGTEST-231" d.txt "BRGTEST-221" e.txt I want to get... (22 Replies)
Discussion started by: pottic
22 Replies
platform::shell(n)					       Tcl Bundled Packages						platform::shell(n)

__________________________________________________________________________________________________________________________________________________

NAME
platform::shell - System identification support code and utilities SYNOPSIS
package require platform::shell ?1.1.4? platform::shell::generic shell platform::shell::identify shell platform::shell::platform shell _________________________________________________________________ DESCRIPTION
The platform::shell package provides several utility commands useful for the identification of the architecture of a specific Tcl shell. This package allows the identification of the architecture of a specific Tcl shell different from the shell running the package. The only requirement is that the other shell (identified by its path), is actually executable on the current machine. While for most platform this means that the architecture of the interrogated shell is identical to the architecture of the running shell this is not generally true. A counter example are all platforms which have 32 and 64 bit variants and where a 64bit system is able to run 32bit code. For these running and interrogated shell may have different 32/64 bit settings and thus different identifiers. For applications like a code repository it is important to identify the architecture of the shell which will actually run the installed packages, versus the architecture of the shell running the repository software. COMMANDS
platform::shell::identify shell This command does the same identification as platform::identify, for the specified Tcl shell, in contrast to the running shell. platform::shell::generic shell This command does the same identification as platform::generic, for the specified Tcl shell, in contrast to the running shell. platform::shell::platform shell This command returns the contents of tcl_platform(platform) for the specified Tcl shell. KEYWORDS
operating system, cpu architecture, platform, architecture platform::shell 1.1.4 platform::shell(n)
All times are GMT -4. The time now is 04:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy