Jonas has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I'm needing to check the FTP port on my server to see if a particular username is logged in at the time the script runs.

Any help would be great... Thanks

Replies are listed 'Best First'.
Re: FTP listening
by httptech (Chaplain) on Apr 16, 2000 at 18:39 UTC
    What FTP server software are you using? Some have an "ftpwho" command that will give you a list of who is logged in at any given moment. That would be easily parseable.

    Short of that you'll probably have to write a script parse the logfile format looking for the username, which will also depend on which FTP server you use, and probably be more complex than the ftpwho method.

RE: FTP listening
by Jonathan (Curate) on Apr 17, 2000 at 12:43 UTC
    Monitoring FTP usage is operating system dependent. For example, with Solaris the 'last' command can be filtered for ftp sessions. While 'netstat -a' can also be filtered if you know the listening address. If you are using NT you have my pity ;-) - but no help from me.
      The 'last' command looks doable. It works on Linux, (Redhat and Slackware), Unixware and an ancient Ultrix we have here. You could split on the output of 'last' looking for "ftp" and a "still logged in" line. If your utmp file is huge, you might might want to limit the output by time or number of lines With netstat you won't get the username, if thats important to you. If you are using NT, check out Win32::EventLog (Process Win32 Event Logs) on CPAN and Usrstat.exe (Displays user name, full name, and last logon date and time) from the NT Server Resource Kit.
Re: FTP listening
by Jonas (Beadle) on Apr 17, 2000 at 20:19 UTC
    Thanks folks, I'll look into the 'last' command to see what I get.