1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash

#######################
#for monitor ftp service
#by zhangyin
#file inner
#version 1
#date 2020 01 03
#######################

#ftp info

##shengchan peizhi
#Ftp_readHost: 192.2.102.211
#Ftp_readPort: 21
#Ftp_readUserName: susong
#Ftp_readPassword: QingDun0909
#Ftp_readBasePath: /
#
#Ftp_writeHost: 192.2.102.212
#Ftp_writePort: 21
#Ftp_writeUserName: susong
#Ftp_writePassword: QingDun0909
#Ftp_writeBasePath: /

Ftp_readHost: 127.0.0.1
Ftp_readPort: 21
Ftp_readUserName: aegisops
Ftp_readPassword: aegisops
Ftp_readBasePath: data

Ftp_writeHost: 127.0.0.1
Ftp_writePort: 21
Ftp_writeUserName: aegisops
Ftp_writePassword: aegisops
Ftp_writeBasePath: data


Work_dir="/tmp/ftp_monitor/"
Input_file=${Work_dir}Input.file
Inner_info="INNERINFO"
Inner_error="INNERERROR"

echo `date +%s` > ${Input_file}
echo 'outter' >> ${Input_file}

mkdir -p ${Work_dir}

cd ${Work_dir}
rm -fr ${Input_file}
ftp -i -n ${Ftp_readHost} << EOF
user ${Ftp_readUserName} ${Ftp_readPassword}
cd ${Ftp_readBasePath}
get ${Input_file}
del ${Input_file}
EOF
if [[ -e ${Input_file} ]]; then
echo "${Inner_info}" >> ${Input_file}
echo `date +%s` >> ${Input_file}
else
echo "${Inner_error}" >> ${Input_file}
echo `date +%s` >> ${Input_file}
fi

ftp -i -n ${Ftp_writeHost} << EOF
user ${Ftp_writeUserName} ${Ftp_writePassword}
cd ${Ftp_writeBasePath}
put ${Input_file}
EOF