Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Directory Comparison and AlertOnChange.

Status
Not open for further replies.

lanassist

Technical User
Aug 8, 2003
19
IT
Aim : To receive a note via mail every time an authorised user makes an FTP access to a site area and changes the area, be it by up/downloading or cancelling files.

I am not well versed in Perl at all I was wondering if there is a link or tutorial pertaining to the following problem, which I immagine result as child's play to many readers here.

Using perhaps a Cron job, run a script that compares an FTP Directory listing to the preceding listing.
If no differences
exit leaving the 'preceding listing' as a base
else pipe difference to a string = message
recurse till end listing
mail message to mail address
update = overwrite base listing with current
exit

The reason for this question is that if one works with FTP for exchanging data the FTP server does not usually alert the Site Owner of the upload, download or cancel events and thus one is obliged to login and check the current situation. (or worse ... telephone)
I have spoken to several Web Server Adminstrators and it seems that they think Perl is the way.

Any comments, ideas or links would be most appreciated.
Thanks
 
Most FTP output logfiles come with timestamps against activity. I'd recommend simply testing the last modification time of the logfile rather than performing diffs against a held copy of it in order to spot activity with a cron job. One possible danger to consider is whether the log-file is size-limited; if this is so then automated archiving, compression or truncation would have a variety of implications on how you would need to go about coding your scanning code. Another danger is deciding how your code reacts to activity that is still ongoing when it runs - i.e. where the data in the logfile is only partial.

It might be simpler to run the logfile output through a splitter process (such as tee), sending one stream to to the logfile and another to your incipient perl script, at which point you would only have to consider how to react to an active stream.
 
Hi, Thanks for the follow up, however ....

Even today I was with a client for whom I have just registered a simple site. FTP access is naturally included in the service and, as expected, sometimes it is useful and more efficient to transfer files through FTP rather than Email.
As he pointed out quite rightly, 'if I send files to my clients through FTP to their private area, how do they know when the files have been uploaded, or vice versa how could I know if a client has sent me a 20 MB project unless he sends me a warning note through the usual Email service?'

It is good practice to avoid cluttering up Mail services with large file transfers and FTP was prepared exactly for that.
The idea of the server recognising the event and warning the corresponding party of the change seems useful and appropriate here.
It is true that examining Log files could help but one cannot expect clients to do this, above all if it already an effort for them to use FTP rather than blind Email.

This was why I mentioned the idea of examining the differences in the Directory structure/tree since it would indicate the presence or absence of files in the last x units of time.
(One knows that for each directory there is one and only one corresponding authorised user)

Perhaps if one could read a very precise audit log one could get the user name, time of connection, n° files changed, success/failure value etc.

I repeat that I know practically no Perl therefore if you can expound on this or you have another idea, an example would be most appreciated
Thanks.
 
On a brief web search, there are packages which are available that automate the sending of emails when prescribed FTP events occur. Perhaps you might want to examine this as a possible solution instead? Some FTP servers can also be configured to send emails in an event-driven manner.
 
>>On a brief web search, there are packages which are available that automate the sending of emails when prescribed FTP events occur. Perhaps you might want to examine this as a possible solution instead? Some FTP servers can also be configured to send emails in an event-driven manner.

Could you mention the links you found and add the types of FTP server ? BTW are you implying that the Perl script idea is too difficult or inappropriate here?

I doubt that this is not the first time somebody asks this question. I would have thought that there is already a simple solution /configuration
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top