当前位置: 技术问答>linux和unix
麻烦高手帮我看一个程序!
来源: 互联网 发布时间:2015-07-08
本文导语: 这是一个自动的取数据文件后并录入数据库的程序,因为我是linux新手,希望有高手帮我看看并分析分析里面的原理和相关命令,最好能逐句解释说明一下,不胜感激了! #!/bin/sh rsyyearmonthday=$rsyymd export rsyyearmonthday u...
这是一个自动的取数据文件后并录入数据库的程序,因为我是linux新手,希望有高手帮我看看并分析分析里面的原理和相关命令,最好能逐句解释说明一下,不胜感激了!
#!/bin/sh
rsyyearmonthday=$rsyymd
export rsyyearmonthday
until [ "$cr" -eq 0 -a "$csh" -eq 0 -a "$smr" -eq 0 -a "$pdscp" -eq 0 ]
do
if [ ! -f $HOME/files/siemens/callrecord/siemens_crlist${rsyyearmonthday}_20.txt.gz ]; then
cr=1
else
cr=0
fi
if [ ! -f $HOME/files/siemens/csh/siemens_cshlist${rsyyearmonthday}_20.txt.gz ]; then
csh=1
else
csh=0
fi
if [ ! -f $HOME/files/siemens/smr/siemens_smrlist${rsyyearmonthday}_20.txt.gz ]; then
smr=1
else
smr=0
fi
if [ ! -f $HOME/files/siemens/pdscp/siemens_pdscplist${rsyyearmonthday}_20.txt.gz ]; then
pdscp=1
else
pdscp=0
fi
if [ "$cr" -eq 1 -o "$csh" -eq 1 -o "$smr" -eq 1 -o "$pdscp" -eq 1 ]; then
echo passive > /tmp/ftp_cmd
echo prompt >> /tmp/ftp_cmd
echo cd siemens/callrecord >> /tmp/ftp_cmd
echo lcd files/siemens/callrecord >> /tmp/ftp_cmd
if [ "$cr" -eq 1 ]; then
echo get siemens_crlist${rsyyearmonthday}_20.txt.gz >> /tmp/ftp_cmd
fi
echo cd ../csh >> /tmp/ftp_cmd
echo lcd ../csh >> /tmp/ftp_cmd
if [ "$csh" -eq 1 ]; then
echo get siemens_cshlist${rsyyearmonthday}_20.txt.gz >> /tmp/ftp_cmd
fi
echo cd ../smr >> /tmp/ftp_cmd
echo lcd ../smr >> /tmp/ftp_cmd
if [ "$smr" -eq 1 ]; then
echo get siemens_smrlist${rsyyearmonthday}_20.txt.gz >> /tmp/ftp_cmd
fi
echo cd ../pdscp >> /tmp/ftp_cmd
echo lcd ../pdscp >> /tmp/ftp_cmd
if [ "$pdscp" -eq 1 ]; then
echo get siemens_pdscplist${rsyyearmonthday}_20.txt.gz >> /tmp/ftp_cmd
fi
echo bye >> /tmp/ftp_cmd
ftp 211.96.31.234 2121 > /tmp/ftp_cmd
echo lcd ../smr >> /tmp/ftp_cmd
if [ "$smr" -eq 1 ]; then
echo get siemens_smrlist${rsyyearmonthday}_20.txt.gz >> /tmp/ftp_cmd
fi
echo cd ../pdscp >> /tmp/ftp_cmd
echo lcd ../pdscp >> /tmp/ftp_cmd
if [ "$pdscp" -eq 1 ]; then
echo get siemens_pdscplist${rsyyearmonthday}_20.txt.gz >> /tmp/ftp_cmd
fi
echo bye >> /tmp/ftp_cmd
ftp 211.96.31.234 2121 /tmp/ftp_cmd
echo prompt >> /tmp/ftp_cmd
echo cd siemens/callrecord >> /tmp/ftp_cmd
echo lcd files/siemens/callrecord >> /tmp/ftp_cmd
if [ "$cr" -eq 1 ]; then
echo get siemens_crlist${rsyyearmonthday}_20.txt.gz >> /tmp/ftp_cmd
fi
echo cd ../csh >> /tmp/ftp_cmd
echo lcd ../csh >> /tmp/ftp_cmd
if [ "$csh" -eq 1 ]; then
echo get siemens_cshlist${rsyyearmonthday}_20.txt.gz >> /tmp/ftp_cmd
fi
echo cd ../smr >> /tmp/ftp_cmd
echo lcd ../smr >> /tmp/ftp_cmd
if [ "$smr" -eq 1 ]; then
echo get siemens_smrlist${rsyyearmonthday}_20.txt.gz >> /tmp/ftp_cmd
fi
echo cd ../pdscp >> /tmp/ftp_cmd
echo lcd ../pdscp >> /tmp/ftp_cmd
if [ "$pdscp" -eq 1 ]; then
echo get siemens_pdscplist${rsyyearmonthday}_20.txt.gz >> /tmp/ftp_cmd
fi
echo bye >> /tmp/ftp_cmd
#传输文件
ftp 211.96.31.234 2121 > /tmp/ftp_cmd
echo lcd ../smr >> /tmp/ftp_cmd
if [ "$smr" -eq 1 ]; then
echo get siemens_smrlist${rsyyearmonthday}_20.txt.gz >> /tmp/ftp_cmd
fi
echo cd ../pdscp >> /tmp/ftp_cmd
echo lcd ../pdscp >> /tmp/ftp_cmd
if [ "$pdscp" -eq 1 ]; then
echo get siemens_pdscplist${rsyyearmonthday}_20.txt.gz >> /tmp/ftp_cmd
fi
echo bye >> /tmp/ftp_cmd
#从211.*这个地址取文件
ftp 211.96.31.234 2121
#!/bin/sh
rsyyearmonthday=$rsyymd
export rsyyearmonthday
until [ "$cr" -eq 0 -a "$csh" -eq 0 -a "$smr" -eq 0 -a "$pdscp" -eq 0 ]
do
if [ ! -f $HOME/files/siemens/callrecord/siemens_crlist${rsyyearmonthday}_20.txt.gz ]; then
cr=1
else
cr=0
fi
if [ ! -f $HOME/files/siemens/csh/siemens_cshlist${rsyyearmonthday}_20.txt.gz ]; then
csh=1
else
csh=0
fi
if [ ! -f $HOME/files/siemens/smr/siemens_smrlist${rsyyearmonthday}_20.txt.gz ]; then
smr=1
else
smr=0
fi
if [ ! -f $HOME/files/siemens/pdscp/siemens_pdscplist${rsyyearmonthday}_20.txt.gz ]; then
pdscp=1
else
pdscp=0
fi
if [ "$cr" -eq 1 -o "$csh" -eq 1 -o "$smr" -eq 1 -o "$pdscp" -eq 1 ]; then
echo passive > /tmp/ftp_cmd
echo prompt >> /tmp/ftp_cmd
echo cd siemens/callrecord >> /tmp/ftp_cmd
echo lcd files/siemens/callrecord >> /tmp/ftp_cmd
if [ "$cr" -eq 1 ]; then
echo get siemens_crlist${rsyyearmonthday}_20.txt.gz >> /tmp/ftp_cmd
fi
echo cd ../csh >> /tmp/ftp_cmd
echo lcd ../csh >> /tmp/ftp_cmd
if [ "$csh" -eq 1 ]; then
echo get siemens_cshlist${rsyyearmonthday}_20.txt.gz >> /tmp/ftp_cmd
fi
echo cd ../smr >> /tmp/ftp_cmd
echo lcd ../smr >> /tmp/ftp_cmd
if [ "$smr" -eq 1 ]; then
echo get siemens_smrlist${rsyyearmonthday}_20.txt.gz >> /tmp/ftp_cmd
fi
echo cd ../pdscp >> /tmp/ftp_cmd
echo lcd ../pdscp >> /tmp/ftp_cmd
if [ "$pdscp" -eq 1 ]; then
echo get siemens_pdscplist${rsyyearmonthday}_20.txt.gz >> /tmp/ftp_cmd
fi
echo bye >> /tmp/ftp_cmd
ftp 211.96.31.234 2121 > /tmp/ftp_cmd
echo lcd ../smr >> /tmp/ftp_cmd
if [ "$smr" -eq 1 ]; then
echo get siemens_smrlist${rsyyearmonthday}_20.txt.gz >> /tmp/ftp_cmd
fi
echo cd ../pdscp >> /tmp/ftp_cmd
echo lcd ../pdscp >> /tmp/ftp_cmd
if [ "$pdscp" -eq 1 ]; then
echo get siemens_pdscplist${rsyyearmonthday}_20.txt.gz >> /tmp/ftp_cmd
fi
echo bye >> /tmp/ftp_cmd
ftp 211.96.31.234 2121 /tmp/ftp_cmd
echo prompt >> /tmp/ftp_cmd
echo cd siemens/callrecord >> /tmp/ftp_cmd
echo lcd files/siemens/callrecord >> /tmp/ftp_cmd
if [ "$cr" -eq 1 ]; then
echo get siemens_crlist${rsyyearmonthday}_20.txt.gz >> /tmp/ftp_cmd
fi
echo cd ../csh >> /tmp/ftp_cmd
echo lcd ../csh >> /tmp/ftp_cmd
if [ "$csh" -eq 1 ]; then
echo get siemens_cshlist${rsyyearmonthday}_20.txt.gz >> /tmp/ftp_cmd
fi
echo cd ../smr >> /tmp/ftp_cmd
echo lcd ../smr >> /tmp/ftp_cmd
if [ "$smr" -eq 1 ]; then
echo get siemens_smrlist${rsyyearmonthday}_20.txt.gz >> /tmp/ftp_cmd
fi
echo cd ../pdscp >> /tmp/ftp_cmd
echo lcd ../pdscp >> /tmp/ftp_cmd
if [ "$pdscp" -eq 1 ]; then
echo get siemens_pdscplist${rsyyearmonthday}_20.txt.gz >> /tmp/ftp_cmd
fi
echo bye >> /tmp/ftp_cmd
#传输文件
ftp 211.96.31.234 2121 > /tmp/ftp_cmd
echo lcd ../smr >> /tmp/ftp_cmd
if [ "$smr" -eq 1 ]; then
echo get siemens_smrlist${rsyyearmonthday}_20.txt.gz >> /tmp/ftp_cmd
fi
echo cd ../pdscp >> /tmp/ftp_cmd
echo lcd ../pdscp >> /tmp/ftp_cmd
if [ "$pdscp" -eq 1 ]; then
echo get siemens_pdscplist${rsyyearmonthday}_20.txt.gz >> /tmp/ftp_cmd
fi
echo bye >> /tmp/ftp_cmd
#从211.*这个地址取文件
ftp 211.96.31.234 2121