"lsof is a command meaning "list open files", which is used in many Unix-like systems to report a list of all open files and the processes that opened them."
The key word is "open". Ultimately I want to know if a particular file is still being written to.
Working on a small project that monitors a file download and performs an action when completed. Currently looking for the file comment to be entered but would prefer a more robust solution.
Not sure how they might be used; I don't need something to initiate a download - anything like a browser or ftp client can do that - I need a method of indicating a download has completed (successfully).
A crude hack would be to poll the file size and check that it has not increased say... 5 times in row.
But I guess the issue would be getting the name of the file in the first place. You could assume the most recent file in the directory is the downloadee. But then you need to know the location of the download directory.
If liberty means anything at all, it means the right to tell people what they do not want to hear. George Orwell.
I've already rejected that approach as it can't distinguish between a download that has completed and a download that has failed or stalled. My current hack is more reliable.
Download directory is not a problem, its always looking in a specific place. It will process all files in there that have completed download.
Perhaps you could try opening the file, on the assumption that any file that is actively being written is going to have an exclusive lock on it, so opening it will fail. If the open succeeds, the file must have been closed and the lock released. If using a DOS script, you could use any DOS command that opens a file and does something harmless if it succeeds (i.e. CountLines).
Okay I see. By the looks of it there isn't a command to do that. I think that is slightly lower level as that descends into DOS internals. We don't even have a top command. I didn't realise it until I needed it that we can't even do something as simple as listing current tasks. To see what is hogging CPU.
The suggestion for a DOS function maybe the way to go if you use ARexx as ARexx can call library functions. I'm not sure if ARexx can actually list open files but ARexx tends to go deeper than what DOS scripts can provide.
Aside from that writing your own binary to use as a command is another solution but more work. However sometimes it's needed on AmigaOS.
Actually we have at least 2 of them. However, my "top" can't be used in DOS or ARexx scripts since it running infinitely until you stop it with Ctrl-C, but maybe Capehill's "Tequila" can be used that way.