- 论坛徽章:
- 0
|
hi all, I met a strange question of shell.
can anyone help me?
有两台服务器,有相同的文件结构。
Group1
\user1
\\download
\\upload
\user2
\\download
\\upload
我希望能够定时将A server的upload文件夹内的内容ftp到b Server对应用户的download文件夹中。
我希望能够通过下面两个shell达到目的,事实上,也是可行的。但是问题时
我用root用户登录服务器之后,run doftp.sh是没什么问题的。可是当我用crontab来run这个shell之后,就遇到了问题。可能是由于文件层数太多。shell run到某个文件夹之后就停止了。
一开始我认为是由于该文件夹内有特殊的文件。所以我就将该文件夹删除。
但是shell仍然不能正常运行。希望遇到过同样问题的人能帮忙解决。或者给出一些建议。谢谢
doftp.sh:
sh /root/ftp/ftp.sh /home/ftpadmin
date +%x' '%X' done ok' >> log
ftp.sh:
for i in $1/* ; do
if [ -d $i ] ; then
# is dir
# first run this shell to the direcory
sh /root/ftp/ftp.sh $i
# find the upload directory in this direcrory
cd $i
if [ -f "upload/over.txt" ] ; then
# delete the flag file
rm -f upload/over.txt
# now do ftp the remost host
ftpdir=${i##/home/ftpadmin/}
#define ftp host and user name
TARGET_FTP="192.168.0.1"
TARGET_DIR="$ftpdir/download"
USER="user"
PASSWD="password"
ftp -i -n $TARGET_FTP <<END
user $USER $PASSWD
passive
bi
cd $TARGET_DIR
lcd $i/upload
prompt
mput *
bye
END
# now move the file to backup directory
mv -f upload/* /ftptemp/$ftpdir
fi
fi
done |
|