LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 11-26-2007, 12:29 AM   #1
champak
LQ Newbie
 
Registered: Nov 2007
Posts: 20

Rep: Reputation: 0
lsof permission


Hi..
This is related to the question http://www.linuxquestions.org/questi...ogress-600769/

Im using lsof to track a file transfer.Im moving the file that is completely FTP transfered.
If I use "su" and then execute lsof, Im able to see the file transfer and abort the "mv"..
But as a user I cldn find in lsof, the file under FTP transfer.
Is there any way the user can be added to see the FTP transfered file in lsof?

Thanks,
Ananth
 
Old 11-26-2007, 12:51 AM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Why not just use the "hash" command in the FTP session to track the progress? Or send using some tool which displays progress somehow...
 
Old 11-26-2007, 01:49 AM   #3
champak
LQ Newbie
 
Registered: Nov 2007
Posts: 20

Original Poster
Rep: Reputation: 0
The problem is I dont have the control over the ftp session. My script (automated scripts,supposed to do the tasks described above) resides in the site receiving the tranfered files. So the script has to identify the completely transfered files before moving them.
 
Old 11-26-2007, 02:36 AM   #4
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
what are you trying to do?

it very very difficult to keep track of ftp sessions and the like.
I wouldn't try if you want an easy life.

why not send a list of the files and their cksums, first of all,
these can then be double checked on receipt.
 
Old 11-26-2007, 02:57 AM   #5
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
I see. Incidentally, how are you monitoring the progress using lsof as root, and what version of lsof / the OS are you using?

For files coming to your machine, you can simply look to see the size of the incoming file, so I assume it is the other way round, and that you do not have access to the remote machine to look and see how much of the file has arrived there....

There is a way, assuming the ftp client is not doing anything fancy with the file (like opening multiple connections and sending more than one part of the file at once). The vanilla ftp client which comes with most distros should be fine with the following method.

In the /proc filesystem, you will see a directory which corresponds to your ftp client process. To find the process ID, do something like this:
Code:
% ps aux |grep ftp
matthew  20917  0.1  0.2   2804  1368 pts/2    S+   08:44   0:00 ftp iggy.local
Here you can see the PID of the ftp client process is 20917. Look in /proc/20917/fd and you will see a list of links to files which the ftp client has open:
Code:
% cd /proc/20917/fd ; ls -l
total 0
lrwx------ 1 matthew matthew 64 2007-11-26 08:44 0 -> /dev/pts/2
lrwx------ 1 matthew matthew 64 2007-11-26 08:44 1 -> /dev/pts/2
lrwx------ 1 matthew matthew 64 2007-11-26 08:44 2 -> /dev/pts/2
lrwx------ 1 matthew matthew 64 2007-11-26 08:44 3 -> socket:[228845]
lrwx------ 1 matthew matthew 64 2007-11-26 08:44 4 -> socket:[228845]
lrwx------ 1 matthew matthew 64 2007-11-26 08:44 5 -> socket:[228845]
lr-x------ 1 matthew matthew 64 2007-11-26 08:44 6 -> /tmp/file_being_put_to_remotehost
lrwx------ 1 matthew matthew 64 2007-11-26 08:44 8 -> socket:[228921]
The file I am putting to the remote host is /tmp/file_being_put_to_remotehost, which corresponds to file handle number 6.

In the /proc/20917/fdinfo directory there is also a file called 6. If I cat this file, I get this sort of thing:
Code:
cat /proc/20917/fdinfo/6
pos:    14991360
flags:  0100000
I assume the pos is the current offset in the file which is being read. When I run the cat command again, I see the value incremented by an amount which seems consistent with the idea that this is tracking how far through the file the reading is. This should give some indication of how far through the file you are.
 
  


Reply

Tags
filesystem, ftp, lsof, proc



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
C Library for lsof loki.guz_BR Linux - Security 2 01-08-2021 01:06 AM
lsof redirect WRXSTi Programming 8 10-02-2006 03:45 PM
What to do when lsof fails.... SpacedCowboy Linux - Security 2 10-29-2005 02:39 PM
Lsof Is Useless?? Philip_38 Linux - Software 3 01-30-2005 09:24 AM
lsof: command not found ionian2k Linux - Newbie 1 12-26-2002 08:59 PM

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

All times are GMT -5. The time now is 03:35 AM.

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