1833337 Members
2503 Online
110051 Solutions
New Discussion

ftplog

 
maxpayne
Occasional Contributor

ftplog

Hi,
I need a script that can ftp daily from serverA to ServerB and get the ftplog with the time between 0500 - 0600 from /var/log/ftplog. It will send an sms alert if the content of the log indicate "lost connection".

Thank you.
3 REPLIES 3
Peter Godron
Honored Contributor

Re: ftplog

Hi,

#!/usr/bin/sh
ftp -n ServerB << EOF
user usr passwd
cd /var/log
get ftplog
bye
EOF

# Define timeframe
start=`date +"%b %d 05"`
end==`date +"%b %d 06"`
# Extract records,look for string, count
status=`awk "/$start/,/$end/" ftplog | grep -i "lost connection" | wc -l`
# If we have more than 0 hits
if [ $status ]
then
echo "lost connection" | mailx pager@office.company
fi
Steven E. Protter
Exalted Contributor

Re: ftplog

Shalom,

The structure Peter posted will let you run a long list of files to transfer into this script, essentially using it as a function.

To add your SMS component, you need two things.

A front end to permit you to essentially re-route an email to SMS and perhaps, based on network needs/secureity an sms relay server that will be permitted to use ports normally closed on corporate lans.

You need to find out what your security situation will permit prior to doing anything about sms.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Peter Godron
Honored Contributor

Re: ftplog

Hi,
Could you please update/close the thread by awarding points to helpful answers and summarising the solution for you.
This will help resolution of similar problems in the future.