Sponsored Content
Operating Systems Linux SuSE When a FTP download is completed Post 75266 by Perderabo on Thursday 16th of June 2005 12:00:44 PM
Old 06-16-2005
Quote:
Originally Posted by Javi
The command 'lsof' doesn't show the file that the 'vsftpd' process is writting. I get the same problem with 'fuser'.

I have made a C program that lock in exclusive mode the file. I thought that If I am able to lock the file then the file is not open by another process. But It doesn't work, the program is able to lock the file although the file is downloading.

The real problem appear to be that, nowhere in the Linux system reside information about the files than the vsftpd daemon is working with ...
Re paragraph 1: I find it very hard to believe that lsof can't do this. Your lsof could be broken, more more likely you are doing something wrong. Since you haven't mentioned stuff like precisely what command you used or precisely what result you got there's no way to tell. Could you take a bug report like: "'lsof' doesn't show the file" and do anything with it?

Re paragraph 2: "exclusive locks" are the only kind that exist. If you want a mandatory lock, read mandatory.txt. But this won't help much. If you do it correctly, you will succeed, and vxftpd will experience failed writes. It will probably detect this and inform the ftp client of the error.

Re paragraph 3: I wonder how the data gets to the file?

I looked at the source code for vsftpd. I see it has a logging option. Turn that on and parse the log to see if the file is finished.
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
FLOCK(2)						     Linux Programmer's Manual							  FLOCK(2)

NAME
flock - apply or remove an advisory lock on an open file SYNOPSIS
#include <sys/file.h> int flock(int fd, int operation); DESCRIPTION
Apply or remove an advisory lock on the open file specified by fd. The argument operation is one of the following: LOCK_SH Place a shared lock. More than one process may hold a shared lock for a given file at a given time. LOCK_EX Place an exclusive lock. Only one process may hold an exclusive lock for a given file at a given time. LOCK_UN Remove an existing lock held by this process. A call to flock() may block if an incompatible lock is held by another process. To make a nonblocking request, include LOCK_NB (by ORing) with any of the above operations. A single file may not simultaneously have both shared and exclusive locks. Locks created by flock() are associated with an open file table entry. This means that duplicate file descriptors (created by, for exam- ple, fork(2) or dup(2)) refer to the same lock, and this lock may be modified or released using any of these descriptors. Furthermore, the lock is released either by an explicit LOCK_UN operation on any of these duplicate descriptors, or when all such descriptors have been closed. If a process uses open(2) (or similar) to obtain more than one descriptor for the same file, these descriptors are treated independently by flock(). An attempt to lock the file using one of these file descriptors may be denied by a lock that the calling process has already placed via another descriptor. A process may only hold one type of lock (shared or exclusive) on a file. Subsequent flock() calls on an already locked file will convert an existing lock to the new lock mode. Locks created by flock() are preserved across an execve(2). A shared or exclusive lock can be placed on a file regardless of the mode in which the file was opened. RETURN VALUE
On success, zero is returned. On error, -1 is returned, and errno is set appropriately. ERRORS
EBADF fd is not an open file descriptor. EINTR While waiting to acquire a lock, the call was interrupted by delivery of a signal caught by a handler; see signal(7). EINVAL operation is invalid. ENOLCK The kernel ran out of memory for allocating lock records. EWOULDBLOCK The file is locked and the LOCK_NB flag was selected. CONFORMING TO
4.4BSD (the flock() call first appeared in 4.2BSD). A version of flock(), possibly implemented in terms of fcntl(2), appears on most Unix systems. NOTES
flock() does not lock files over NFS. Use fcntl(2) instead: that does work over NFS, given a sufficiently recent version of Linux and a server which supports locking. Since kernel 2.0, flock() is implemented as a system call in its own right rather than being emulated in the GNU C library as a call to fcntl(2). This yields true BSD semantics: there is no interaction between the types of lock placed by flock() and fcntl(2), and flock() does not detect deadlock. flock() places advisory locks only; given suitable permissions on a file, a process is free to ignore the use of flock() and perform I/O on the file. flock() and fcntl(2) locks have different semantics with respect to forked processes and dup(2). On systems that implement flock() using fcntl(2), the semantics of flock() will be different from those described in this manual page. Converting a lock (shared to exclusive, or vice versa) is not guaranteed to be atomic: the existing lock is first removed, and then a new lock is established. Between these two steps, a pending lock request by another process may be granted, with the result that the conver- sion either blocks, or fails if LOCK_NB was specified. (This is the original BSD behavior, and occurs on many other implementations.) SEE ALSO
close(2), dup(2), execve(2), fcntl(2), fork(2), open(2), lockf(3) See also Documentation/filesystem/locks.txt in the kernel source (Documentation/locks.txt in older kernels). COLOPHON
This page is part of release 3.25 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. Linux 2009-07-25 FLOCK(2)
All times are GMT -4. The time now is 02:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy