如何在shell脚本里使用sftp批量传送文件
1个回答
2015-11-01
展开全部
#!/bin/bash
# your answer
#
# upload TARGETS to $FTPIP$FTPDIR
FTPCMD=ftp.cmd
FTPIP=127.0.0.1
FTPUSER=anonymous
FTPPWD=ftp@kernel.org
FTPDIR=/rootdir/ftp/dir
TARGETS=./target/*
echo open $FTPIP>$FTPCMD
echo user $FTPUSER $FTPPWD>>$FTPCMD
echo cd $FTPDIR>>$FTPCMD
echo mput $TARGETS>>$FTPCMD
ftp -ivn<$FTPCMD
rm -f $FTPCMD
# download $FTPIP$FTPDIR$FTPTARGETS to $TARGETS
FTPIP=kernel.org
FTPUSER=anonymous
FTPPWD=kernel@kernel.org
FTPDIR=/pub/linux/kernel/Historic/old-versions/
TARGETS=./*.tar.?z
TARGETDIR=targets
echo open $FTPIP>$FTPCMD
echo user $FTPUSER $FTPPWD>>$FTPCMD
echo cd $FTPDIR>>$FTPCMD
echo mget $TARGETS>>$FTPCMD
if [ test -d $TARGETDIR ]; then
rm -rf $TARGETDIR
fi
mkdir $TARGETDIR
ftp -ivn<../$FTPCMD
cd ..
rm -f $FTPCMD
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询