ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi, i'm writing a script to monitor the process of a file being uploaded and then once that file transfer has been complete to disconnect the other party. But how do i go about monitoring the progress of the file.
Currently i'm just doing a 'ls -l <file> and awking the file size every 5 seconds in a loop and if the file size doesn't change then i assume it's complete. Is there another way to go about that? I've checked all the command operators such as -f and -e but they don't seem to work while uploading a file and give a return code of $? = 0. Also i've tried using the 'touch' option to but that doesn't work either.
You know, that doesn't sound all too bad, perhaps the code could be stream lined or something to make it faster, since you're obviously not happy with it as is. But I find myself asking uploaded how? Many of the ftpd's can alter the file some how when it's finished being uploaded. If in fact you are using ftp. If I recall correctly proftpd can even run a script or program on a file once it's been finished, I'm certainly many of the others can do something of the kind. Or lacking that feature most if not all half way good ftp daemons they will chmod the file that was just uploaded to something like 644 so that it can't be deleted.
Sorry I didn't have any better suggestions but what you sounds fine to me.
i work at a business where clients ftp files into our server. However, sometimes they stay logged on and don't log off, which is why i need to make this script. So the ftpd scripts you're talking about are only client side ( incomming) but my clients systems range from various types, that's why i need to have the script running on my end of the server. It's just using the standard linux ftp. The problem is, TCP/IP won't recognize the diff between a slow down or a complete disconnect and therefore will try indefinately to finish sending the file. So lets' say the file is 1000000kb and they start uploading, then you can do a listing say every 2 secs and the byte size will change, but now for instance if the user has only uploaded 999,999 k and the internet halts, and my timer, say.. 10 secs gives up then
ls -l <file> | awk '(print $5)' > size1 is going to equal size2. That's my problem. I'll check tomorrow to see if the permissions are different while uploading and if they change after the file is finished.
Any other ideas? I know my problem is quite unique...
I'm not sure which ftp daemon you are using. But most daemons should be able to automatically close idle connections. Proftpd can do it by setting the TimeoutIdle directive.
Setting the timer to 10 seconds is very low and you might get a lot of unnecessary disconnects when the connections stalls for a bit. A client that isn't doing anything for a while doesn't cause that much overhead so increasing the timer to a higher value shouldn't be a big disaster. I have mine set to the default of 10 minutes.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.