I see. Incidentally, how are you monitoring the progress using
lsof as root, and what version of lsof / the OS are you using?
For files coming to your machine, you can simply look to see the size of the incoming file, so I assume it is the other way round, and that you do not have access to the remote machine to look and see how much of the file has arrived there....
There is a way, assuming the
ftp client is not doing anything fancy with the file (like opening multiple connections and sending more than one part of the file at once). The vanilla ftp client which comes with most distros should be fine with the following method.
In the
/proc filesystem, you will see a directory which corresponds to your ftp client process. To find the process ID, do something like this:
Code:
% ps aux |grep ftp
matthew 20917 0.1 0.2 2804 1368 pts/2 S+ 08:44 0:00 ftp iggy.local
Here you can see the PID of the ftp client process is
20917. Look in
/proc/20917/fd and you will see a list of links to files which the ftp client has open:
Code:
% cd /proc/20917/fd ; ls -l
total 0
lrwx------ 1 matthew matthew 64 2007-11-26 08:44 0 -> /dev/pts/2
lrwx------ 1 matthew matthew 64 2007-11-26 08:44 1 -> /dev/pts/2
lrwx------ 1 matthew matthew 64 2007-11-26 08:44 2 -> /dev/pts/2
lrwx------ 1 matthew matthew 64 2007-11-26 08:44 3 -> socket:[228845]
lrwx------ 1 matthew matthew 64 2007-11-26 08:44 4 -> socket:[228845]
lrwx------ 1 matthew matthew 64 2007-11-26 08:44 5 -> socket:[228845]
lr-x------ 1 matthew matthew 64 2007-11-26 08:44 6 -> /tmp/file_being_put_to_remotehost
lrwx------ 1 matthew matthew 64 2007-11-26 08:44 8 -> socket:[228921]
The file I am putting to the remote host is
/tmp/file_being_put_to_remotehost, which corresponds to file handle number
6.
In the
/proc/20917/fdinfo directory there is also a file called
6. If I cat this file, I get this sort of thing:
Code:
cat /proc/20917/fdinfo/6
pos: 14991360
flags: 0100000
I assume the pos is the current offset in the file which is being read. When I run the
cat command again, I see the value incremented by an amount which seems consistent with the idea that this is tracking how far through the file the reading is. This should give some indication of how far through the file you are.