免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1250 | 回复: 3
打印 上一主题 下一主题

关于shell递归的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-06-11 12:52 |只看该作者 |倒序浏览
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

论坛徽章:
0
2 [报告]
发表于 2004-06-11 12:53 |只看该作者

关于shell递归的问题

我的服务器是turbo linux 8.0

论坛徽章:
0
3 [报告]
发表于 2004-06-11 17:06 |只看该作者

关于shell递归的问题

你的crontab使怎样写的?

论坛徽章:
0
4 [报告]
发表于 2004-06-11 21:38 |只看该作者

关于shell递归的问题

0,30 * * * * sh /root/ftp/doftp.sh
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP