Linux 下面的NCFTP相关脚本
最近要测试一下ftp上传速度,及远程删除ftp服务器上上传上去的文件,于是写了下面的脚本。
记录下来,以便记忆。
这个脚本里面有一个东西一直没有弄的太明白,今天请教了bsd群里面的兄弟,老田给解疑了。谢谢!~
就是:
if [ $? == '0' ];then
这个判断的意思就是,前面的脚本或者是命令执行的结果,是0 还是1 是0就为真(命令或者脚本执行成功),是1就为假(命令或者脚本执行失败)
具体脚本如下:
#!/bin/bash
#
# Need to Install the ncftp Client soft
# Create By Kevin
# Mail
#
PATH=/sbin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
IP=192.168.0.208
####这里是远程删除FTP服务器上面的文件 脚本
echo " Starting Delete the file of the ftp server..." >> /root/ftp.log
echo `date` >> /root/ftp.log
ncftp -u dengxb -p 192.168.0.208 <cd YXD_IGS/fyong
rm -rf sogou_pinyin_43b.rar
quit
END_OF_CMD
echo "Down..." >> /root/ftp.log
echo `date` >> /root/ftp.log
echo -e "-------------- Delete the file -------------------- \n" >> /root/ftp.log
##### 这里是上传文件到ftp服务器上面的脚本
echo "Starting Up load the file to the FTP Server..."
echo `date` >> /root/ftp.log
echo "Up load data..." >> /root/ftp.log
upfile()
{
for add in $IP
do
ncftpput -u dengxb -p -P 21 192.168.0.208 /YXD/YXD_IGS/fyong /root/sogou_pinyin_43b.rar >> /root/ftp.log
if [ $? == '0' ];then
echo "Upload file succeed " >> /root/ftp.log
echo `date` >> /root/ftp.log
else
echo "Upload file failed " >> /root/ftp.log
fi
done
}
upfile
echo "Down..." >> /root/ftp.log
echo -e "------------ Up load the file ---------------------- \n" >> /root/ftp.log
echo -e "---------------------------------- \n" >> /root/ftp.log
阅读(981) | 评论(0) | 转发(0) |