When a FTP download is completed


 
Thread Tools Search this Thread
Operating Systems Linux SuSE When a FTP download is completed
# 1  
Old 06-15-2005
When a FTP download is completed

I receive files by FTP in an input directory. Every 10 seconds a process checks if some new file has arrived to the input directory and then the process moves them to another directory to be read by a second process.

The problem is that there is no way to know if the download has finished or not. Sometimes my process moves the file when I have received only a part of it.
Is there any way to know if the FTP download is completed ? I have tested the file with 'lsof', 'stat', ... but it doesn't work.

The same process works fine in AIX. If I try to open a file that is downloading at the same time, I receive an error 'Resource is busy'. I use this error to check if the download is completed. But in Linux ( SuSe ) I don't receive any error.

Thanks
# 2  
Old 06-15-2005
while I believe there's no "bullet-proof" solution to this.... you can try using 'fuser' [or lsof if you have one] to see if a file is being used by someone else.

Worth looking into at least.....
# 3  
Old 06-15-2005
try checking for the ftp connection ...

Code:
#! /bin/ksh

ftpOn=$(netstat -a | awk '/ESTABLISHED/ && /ftp/ {print $2}')

if [ ! $ftpOn ]
then
    echo "ok to proceed"
fi

exit 0


Last edited by Just Ice; 06-15-2005 at 01:20 PM..
# 4  
Old 06-15-2005
there might be multiple unrelated ftp sessions
# 5  
Old 06-15-2005
true ... it might be better to combine the netstat-ftp check with fuser so there is some sort of confirmation that the file is indeed being written to ...
# 6  
Old 06-15-2005
Also, it might be possible to ask the ftp transmitter to send another file when the first ftp is complete. It would be a 0 byte or small file and then you would just check for the existense of that file.
# 7  
Old 06-15-2005
that might sound like the easiest option but that would mean 2 scripts have to be modified ... considering that the same script works well in another platform --- i would opt to just modify 1 script myself as that would keep the appearance of new "features" to a minimum ...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

FTP File download

Hi, I have few files at FTP location and have written a script to download the same from ftp based on the sysdate - 1, however with the below code I am unable to download the files from FTP. x=`TZ=CST+24 date +%Y%m%d` mget Daily_BIH_$x_NEW.tar.gz can anyone please help me in... (10 Replies)
Discussion started by: rramkrishnas
10 Replies

2. Shell Programming and Scripting

Download files every one second using ftp script

Our main Server "Srv1" is used to generate text files based on specified criteria and it is also connected to two clients (pc1 and pc2) which are responsible for getting the files from Srv1 as it follows: 1. pc1 ( which represents my UNIX machine ) uses shell script to copy the files from Srv1 2.... (3 Replies)
Discussion started by: arm
3 Replies

3. Shell Programming and Scripting

Download data from ftp.

Dear all, I am beginner to shell scripting. I have to download more than 1k files from ftp site. link is below ftp://ftp.ncbi.nih.gov/genomes/Bacteria/ Earlier i was using wget url, for download but the problem is some times folder names get changed, i don't know how to move in directories... (4 Replies)
Discussion started by: admax
4 Replies

4. Windows & DOS: Issues & Discussions

Download patches using FTP client

Hi all, I want to download patches using any FTP client by connecting to updates.oracle.com site on windows platform.Please advice me on this. I am using windows xp operating system Thanks in advance (0 Replies)
Discussion started by: William1482
0 Replies

5. UNIX for Dummies Questions & Answers

cURL Active FTP Download

Hello, I know this is probably a very silly question for most but how to do I force curl to do active FTP downloads? Thank you Dallas (2 Replies)
Discussion started by: Dallasbr
2 Replies

6. Shell Programming and Scripting

download specified file from ftp server

Hi all, I'm having problems downloading files from ftp server. I have to download only those files that name starts with YYYYMMDD.But file comes like the format "20080624221035.TXT".Also how i can get list of all file names with in specified folder. Here i paste my code ftp -vn... (1 Reply)
Discussion started by: vaskarbasak
1 Replies

7. UNIX for Dummies Questions & Answers

FTP Download username and password

I am trying to download from ftp server (rsync and postfix). But every time I connect to the ftp server, it prompts for USER and PASS but I don't know which username and and password to use. And I am using command based UNIX OS. (2 Replies)
Discussion started by: kumarrana
2 Replies

8. Shell Programming and Scripting

Cron Jobs for FTP download

Dear All, Please to be inform you,I have posted one thread on this forum last 5 days back. I was not getting suggestions for my thread. So i am creating a new thread with detailed of my R&D. I am new in Shell Scripts, Perl and Cron Jobs. I have one requirement in Cron jobs for FTP Download.... (5 Replies)
Discussion started by: moorthygs
5 Replies

9. HP-UX

ftp download problem

from windows ftp tool even you are not root user you can delete root files (8 Replies)
Discussion started by: mkhsy
8 Replies

10. HP-UX

Ftp Download Problem

FROM WINDOWS , WHILE GETTING DATA FROM HP-UNIX SERVER USING FTP, I AM ABLE TO GET DATA ONLY LESS THAN 4GB FILE, PLZ HELP ME HOW TO GET MORE MORE THAN 4GB FILE. (4 Replies)
Discussion started by: niranjan
4 Replies
Login or Register to Ask a Question