LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-15-2002, 04:12 PM   #1
noodle123
LQ Newbie
 
Registered: Apr 2002
Posts: 27

Rep: Reputation: 15
Question Bourne shell programming


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.

Any ideas would be great.
Great forum btw.

Cheers,

Noodle.
 
Old 04-15-2002, 06:49 PM   #2
kibble
LQ Newbie
 
Registered: Apr 2002
Posts: 14

Rep: Reputation: 1
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.
 
Old 04-15-2002, 10:48 PM   #3
noodle123
LQ Newbie
 
Registered: Apr 2002
Posts: 27

Original Poster
Rep: Reputation: 15
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...

Noodle.
 
Old 04-16-2002, 03:46 AM   #4
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
'sh' shell - Actually calls legacy Bourne shell, or uses system default? Dtsazza Linux - Software 1 10-28-2005 09:20 AM
Help with basic bourne shell script rnj Programming 6 09-13-2005 08:41 PM
bourne shell /etc/passwd /etc/shadow uribo Programming 2 05-09-2003 11:09 PM
Bash Shell vs Bourne infamous41md Linux - Newbie 14 04-11-2003 10:16 PM
Bourne Again SHell help MagInnovision Linux - Newbie 2 02-04-2003 03:43 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration