if [ ! -s /tmp/NEWFILE ]
then
print "Command: grep failed to get any output from FILE: ${FILE}, this file did not contain the word you were looking for, please try again!!"
else
print "Command: grep finished successfully."
fi
If on solaris, the standard distribution should have fuser [as jamisar has mentioned].
If on other OS, try to get 'lsof'
NAME
lsof - list open files
DESCRIPTION
Lsof revision 4.50 lists information about files opened by
processes for the following UNIX dialects:
AIX 4.1.[45], 4.2[.1], and 4.3[.123]
BSDI BSD/OS 2.1, 3.[01], and 4.[01] for Intel-based systems
DC/OSx 1.1 for Pyramid systems
DEC OSF/1, Digital UNIX, Tru64 UNIX 2.0, 3.2, 4.0, and 5.0
FreeBSD 2.1.[67], 2.2[.x], 3.[012345], 4.0, and 5.0 for Intel-
based systems
HP-UX 9.01, 10.20, and 11.00
Linux 2.0.3[2346], 2.1.x, and 2.2.x for Intel-based systems
NetBSD 1.[2345] for Alpha, Intel, and SPARC-based systems
NEXTSTEP 3.[13] for NEXTSTEP architectures
OpenBSD 2.[01234567] for Intel-based systems
OpenStep 4.x
Reliant UNIX 5.4[34] for Pyramid systems
SCO OpenServer Release 3.0 and 5.0.[0245] for Intel-based
systems
SCO UnixWare 2.1.[123] and 7[[.0].1] for Intel-based systems
Sequent PTX 2.1.9, 4.2.[13], 4.[34], 4.4[.1246], and 4.5[.1]
for Sequent systems
Solaris 2.5.1, 2.6, 7, 8 BETA, and 8 BETA-Refresh
SunOS 4.1.x
Ultrix 4.2
DISTRIBUTION
The latest distribution of lsof is available via anonymous
ftp from the host vic.cc.purdue.edu. You'll find the lsof
distribution in the pub/tools/unix/lsof directory.
Lsof is also mirrored elsewhere. When you access
vic.cc.purdue.edu and change to its pub/tools/unix/lsof
directory, you'll be given a list of some mirror sites. The
pub/tools/unix/lsof directory also contains a more complete
list in its mirrors file. Use mirrors with caution - not
all mirrors always have the latest lsof revision.
Some pre-compiled Lsof executables are available on
vic.cc.purdue.edu, but their use is discouraged - it's
better that you build your own from the sources. If you
feel you must use a pre-compiled executable, please read the
cautions that appear in the README files of the
pub/tools/unix/lsof/binaries subdirectories and in the 00*
files of the distribution.
Thanks for your input, ALL.
I stumbled onto something that worked perfectly for me.
It is a simple scenario where I have to concatenate files from a specific production directory. I can't do a "cat * > catfl" because the production job could be writing to the directory at the same time, so I needed some kind of a check.
This is what I came up with using cksum where if the file is still being written to then cksum waits till that completes, and is working great. let me know if you see any issues with this.
#!/bin/ksh
if (( $(ls mb | wc -l) < 1 )); then
exit
fi
set `ls mb`
for i in $*
do
cksum mb/$i 1>/dev/null
if [ $? != 0 ]; then
print "Error getting cksum on $i"
exit
fi
cat mb/$i >> toca
if [ $? == 0 ]; then
rm mb/$i
else
print " Error concatenating $i: $(date '+%m/%d/%y %H:%M:%S')"
fi
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.