1848035 Members
3485 Online
104022 Solutions
New Discussion

Re: ftp tiggering

 
SOLVED
Go to solution

ftp tiggering

hi,
we have an ftp server for customers to put their accounting files to be processed by our company...they put their standart-named file via ftp...every customer has a home directory,
which has two sub-directories,one to put files, the other to get the processed file by the mainframe...the communication between the unix box and the mainframe is done via edm...up to now, we used to have a cron job that works every half an hour and searches for the new files that have been put by customers...but because the number of customers
growed rapidly,we have timing problems with other cron jobs...
is there a way that when the customer ftps the file, i can automatically be aware of this, and trigger the edm program to process the file,thus by avoiding the need for the cron jobs..
thanks...
it's all a game
7 REPLIES 7
Paula J Frazer-Campbell
Honored Contributor

Re: ftp tiggering

Hi

Is the problem that as your customers increase then to circulate and process the file conversions is taking more and more time.

Just an idea can you put in the .profile of the customers dir a small script to identify their logout and then check for the presence of their file and then action it.

HTH

Paula
If you can spell SysAdmin then you is one - anon
Robin Wakefield
Honored Contributor
Solution

Re: ftp tiggering

Hi,

If you set the ftpd to log in verbose mode (add the -l -v switches in /etc/inetd.conf and send the inetd process a HUP signal), you could monitor the log file with something like:

==========================================
#!/bin/ksh

tail -1f /var/adm/syslog/syslog.log | while read line ; do
echo $line | grep -q 'FTP LOGIN'
if [ $? -eq 0 ] ; then
echo $line | sed 's/.*ftpd\[\([^]]*\).*, \(.*\)/\1 \2/' | read pid user
echo $user > /var/tmp/ftp.${pid}
continue
fi
echo $line | grep -q 'FTP: store'
if [ $? -eq 0 ] ; then
echo $line | sed 's/.*ftpd\[\([^]]*\)]: FTP: store \(.*\)$/\1 \2/' | read pid file
echo $file transferred by `cat /var/tmp/ftp.${pid}`
YOUR PROCESS...
fi
done
=====================================

where YOUR PROCESS is the edm transfer procedure. The /var/tmp/ftp.$pid files would contain the username, and would need tidying up occasionally.

Rgds, Robin.
John Palmer
Honored Contributor

Re: ftp tiggering

If all the customer does is create a file then you only have a couple of options:

1. A regular cron job.
2. A 'daemon' process that is always running that regularly checks your incoming directories.

It's also possible to extend the amount of information logged by ftpd (amend /etc/inetd.conf to add the v flag) then change your 'daemon' process to watch the syslog for relevant ftp messages. This is a bit complicated though - what are the 'timing problems' that you are experiencing with cron jobs?

Regards,
John

Re: ftp tiggering

hi,
first of all, when the cron script starts
searching all of the customers directory,
it takes a couple of minutes to finish this job...we search the new files, by comparing their names with the names stored in a special
file-in which the early transferred files names resided in order to not to send them again to pool...the files found as "new" are
all sent to a directory(which we call a "pool"), and a new cron job is started for
edm to transfer these files to mainframe...
the time between these two cron-jobs need to be
little, in order to process the files rapidly...this was o good way before we have
not so many customers,but now it suffers,in both adminastring and problem solving...
that's why, we decide the trigger the scripts..

by the way, a new question:
does ftp users have their .profile executed?
thank u all
it's all a game
harry d brown jr
Honored Contributor

Re: ftp tiggering

You could do something like this, which could be dangerous (potential security issues):

change the name of ftpd, to something like wrapped_ftpd.

Then, create a script like this, called ftpd:

#!/usr/bin/ksh
#
touch /tmp/ftptime_start
/usr/lbin/wrapped_ftpd
touch /tmp/ftptime_stop


Of course, change the "touches" to whatever you want, that will perform a directory scan for newly deposited files.


live free or die
harry
Live Free or Die
harry d brown jr
Honored Contributor

Re: ftp tiggering

Don't forget to change the new ftpd:

chmod 544 ftpd
chown bin:bin ftpd

live free or die
harry
Live Free or Die
Krishna Prasad
Trusted Contributor

Re: ftp tiggering

I agree with Paula's idea of having the edm script get triggered by .profile when they log in to to the ftp.

This would trigger more, but smaller edm scripts.

I would also suggest that the userid be passed as a parameter of the edm script so that you still would only have to maintain one script.
Positive Results requires Positive Thinking