linux commands come packaged with man pages that are manuals for each command's use
they also describe what the command does
just type man in front of the command name..
Code:
lsof - list open files
..
An open file may be a regular file, a directory, a block special file,
a character special file, an executing text reference, a library, a
stream or a network file (Internet socket, NFS file or UNIX domain
socket.) A specific file or all the files in a file system may be
selected by path.
Instead of a formatted display, lsof will produce output that can be
parsed by other programs. See the -F, option description, and the OUT‐
PUT FOR OTHER PROGRAMS section for more information.
so standalone lsof will show all open files on the system..
you could grep out a specific directory
Code:
# lsof | grep /dirA
..
basically while the file is downloading you will see a lot of results in there from all of the different services using the file causing it to be in an open state
once the file is completely downloaded, or the download fails and ceases,
the output of lsof on that directory will be empty
theoretically you could write a bash script that watches a dir and determines if the output of lsof is populated or empty and assign actions for each outcome:
populated : check again in 17 seconds
empty : alert the file has completed downloading
this is useless in determining if the file completely downloaded,
for that you would have to write another part of the script that checks the size of the file on your system to see if it matches the size of the file on the ftp server
also it would be unnecessarily slow,
it would be better to write a script that performs the get and then when the get finishes alerts you with each file