1846552 Members
2126 Online
110256 Solutions
New Discussion

Re: FTP script

 
SOLVED
Go to solution
maxpayne
Occasional Contributor

FTP script

I need a script that can read the /var/log/ftplog and send an sms alert if there is an ftp disconnection. The ftp jobs run daily @ 5 am.

The ftp log shown lost connection

Jul 14 05:00:56 bwbw0066 in.ftpd[21485]: [ID 373804 daemon.info] connection from 10.103.3.4 at Fri Jul 14 05:00:56 2006
Jul 14 05:00:56 bwbw0066 in.ftpd[21485]: [ID 988435 daemon.debug] <--- 220
Jul 14 05:00:56 bwbw0066 in.ftpd[21485]: [ID 738965 daemon.debug] bwbw0066 FTP server (SunOS 5.8) ready.
Jul 14 05:00:56 bwbw0066 in.ftpd[21485]: [ID 577562 daemon.debug] command: USER asftp^M
Jul 14 05:00:56 bwbw0066 in.ftpd[21485]: [ID 988435 daemon.debug] <--- 331
Jul 14 05:00:56 bwbw0066 in.ftpd[21485]: [ID 337738 daemon.debug] Password required for asftp.
Jul 14 05:00:56 bwbw0066 in.ftpd[21485]: [ID 416587 daemon.debug] command: PASS
Jul 14 05:00:56 bwbw0066 in.ftpd[21485]: [ID 988435 daemon.debug] <--- 230
Jul 14 05:00:56 bwbw0066 in.ftpd[21485]: [ID 636382 daemon.debug] User asftp logged in.
Jul 14 05:00:56 bwbw0066 in.ftpd[21485]: [ID 577562 daemon.debug] command: SYST^M
Jul 14 05:00:56 bwbw0066 in.ftpd[21485]: [ID 988435 daemon.debug] <--- 215
Jul 14 05:00:56 bwbw0066 in.ftpd[21485]: [ID 369318 daemon.debug] UNIX Type: L8 Version: SUNOS
Jul 14 05:00:56 bwbw0066 in.ftpd[21485]: [ID 577562 daemon.debug] command: TYPE A^M
Jul 14 05:00:56 bwbw0066 in.ftpd[21485]: [ID 988435 daemon.debug] <--- 200
Jul 14 05:00:56 bwbw0066 in.ftpd[21485]: [ID 735722 daemon.debug] Type set to A.
Jul 14 05:01:00 bwbw0066 in.ftpd[21485]: [ID 103687 daemon.debug] lost connection
2 REPLIES 2
Peter Godron
Honored Contributor
Solution

Re: FTP script

Hi,
one way may be something like:
#!/usr/bin/sh
filename=/var/log/ftplog
# Get todays date
sdate=`date -u "+%b %m"`
# Search for the lost connection and todays date
lfound=`grep -e"$sdate" $filename | grep -e"lost connection"| wc -l`
if [ $lfound -gt 0 ]
then
# send mail
grep -e"$sdate" $filename | grep -e"lost connection" |mailx -s"Lost ftp connection" reciever@mail.com
else
echo "clean run"
fi

In conjunction with SMS thread:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=182232

If you found this answer useful please read:
http://forums1.itrc.hp.com/service/forums/helptips.do?#28
Steven E. Protter
Exalted Contributor

Re: FTP script

Shalom,

Welcome to ITRC.

Most ftp servers do include an inactivity time out.

You appear to be running into that, perhaps due to a large file transfer that is proceeding slowly.

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