Results 1 to 6 of 6
The problem i have is:
A client has a desktop program that uploads images and data to a certain folder where i have a script that imports it to a ...
- 11-14-2010 #1Just Joined!
- Join Date
- Nov 2010
- Posts
- 4
FTP upload user monitoring/notifying
The problem i have is:
A client has a desktop program that uploads images and data to a certain folder where i have a script that imports it to a DB, this all works. But i cant just set it to a hourly cron or have the client run a script after they have uploaded via FTP (the client is not techy).
So I need a way to detect when they have finished uploading all the data via ftp, which i just cant see a way of doing....it would have to be a linux command where it notifies a php script when the client has logged out of ftp, then disables shell access temporarily imports the data they have uploaded then reactivates shell access...but i have no idea what linux commands i would have to look into to get this working.
Any help is much appreciated.
- 11-14-2010 #2
Hmm, the problem -as I understand it- is not reacting to new files.
That can be done via cron or incron.
Rather, the problem is to ensure, that the uploaded files are complete and consistent.
Only a set of files makes sense to be processed, right?
Well, one *could* monitor the ftp serverlog for logout, but that is unreliable for technical and also human error.
Network down, client disconnected for whatever reason,..
An easy approach might be to ask the client to use an archiver such as zip (yes, there are better ones, but you mentioned the client is not a techie)
The zip is just one file, so it is easier to react to that.
Also, it can be checked for corruption before processing.
You will have to negotiate a naming convention, possibly containing some version or date information, as this can ease your scripting.
Another approach is to closely look at what type of files get uploaded.
Maybe the images can be uploaded and processed at any time without harm,
and only the db data upload triggers more sophisticated actions?
But if one depends on the other, then you will run into nasty raceconditions.You must always face the curtain with a bow.
- 11-14-2010 #3Just Joined!
- Join Date
- Nov 2010
- Posts
- 4
Well, one *could* monitor the ftp serverlog for logout, but that is unreliable for technical and also human error.
Network down, client disconnected for whatever reason,..
This is my main worry, the files they upload are images and a csv file so i dont think there is any way i can do a check on them to see if they are not corrupt? or can i?
- 11-14-2010 #4
Another idea:
Is it out of the question, that the client uses subversion? There are graphical (windows) clients.
You would set up a subversion server, reachable via ssh, the loginshell is rush (restricted user shell)
The client would "upload" (aka commit) changes, and your server could react to that via a post commit hook.You must always face the curtain with a bow.
- 11-14-2010 #5Well, the tool "file" can at least tell you, which type of file you are dealing with.This is my main worry, the files they upload are images and a csv file so i dont think there is any way i can do a check on them to see if they are not corrupt? or can i?
You can use it for sanity checks.
About the csv files:
You need to apply filters, that check the content for sanity.
Basically:
Any field your import script expects, needs to be in the csv and in the correct format and limits.You must always face the curtain with a bow.
- 11-14-2010 #6Just Joined!
- Join Date
- Nov 2010
- Posts
- 4
thanks for your help, i think i have an idea now of how to go about getting this to work. I am going to have a cron job which checks to see if any files are uploaded, if they are it will check:
to see if the client is logged in via the who command
check to see if the csv file is complete
then blocks access via chsh
imports
deletes the files
then enables access again with chsh
havent looked into the commands yet but i believe they are what i need to use.


Reply With Quote