LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1130|回复: 8

这个脚本如何写?

[复制链接]
发表于 2005-4-11 13:10:16 | 显示全部楼层 |阅读模式
从网络的一个TFTP或FTP上下载一个镜像,然后灌到某个硬盘里(是固定的hdc)。
请赐教谢谢!
发表于 2005-4-11 20:46:35 | 显示全部楼层
用wget可以实现啊.
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-4-12 10:21:35 | 显示全部楼层
可是如果下载回来再往硬盘灌的话我本地没有足够空间放这个镜像阿!
只能边下载边导入!
回复 支持 反对

使用道具 举报

发表于 2005-4-12 10:57:09 | 显示全部楼层
好高级啊。哈哈。我夜像知道,yuri-master 明白了,就摆出来给我看下,好吗?先谢谢你了,预祝你很快会写这个脚本
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-4-12 12:29:56 | 显示全部楼层
这是一个安全产品的其中一个环节
回复 支持 反对

使用道具 举报

发表于 2005-4-14 23:28:22 | 显示全部楼层
很久没写shell脚本了,正好我也打算做mirror,然后就写了一个比较蹩脚的脚本,希望能给你一点启示


  1. #! /bin/tcsh
  2. # To see wether the system has lftp or not
  3. set lftp
  4. set lftp = `where lftp`
  5. if ( $lftp =~ "lftp:" ) then
  6.     echo "You do not have lftp(8) in your system. Please install one."
  7.     exit
  8. endif

  9. # Set the date for dir name
  10. set today = "date +%m%d"

  11. # Mirror from Maya's FTP of btbbs
  12. cd /root
  13. if ( -e lftp.auto ) then
  14.   rm -f /root/lftp.auto
  15. endif
  16. cd /usr/home/ftp/pub/0day
  17. if ( ! -e $today) then
  18.   mkdir $today
  19. endif
  20. echo "open xxx.xxx.xxx.xxx -p 21" >> /root/lftp.auto
  21. echo "user xxx passwd" >> /root/lftp.auto
  22. echo "cd /need_mirror" >> /root/lftp.auto
  23. echo "mirror -c $today /usr/home/ftp/pub/mirror" >> /root/lftp.auto
  24. echo "bye" >> /root/lftp.auto
  25. lftp -f /root/lftp.auto

  26. # Upload the mirror
  27. cd /root
  28. if ( -e fxp.auto ) then
  29.     rm /root/fxp.auto
  30. endif
  31. cd /usr/home/ftp/pub/0day
  32. echo "open xxx.xxx.xxx.xxx" >> /root/fxp.auto
  33. echo "user username passwd" >> /root/fxp.auto
  34. echo "cd /income" >> /root/fxp.auto
  35. echo "mirror -R $today" >> /root/fxp.auto
  36. echo "bye" >> /root/fxp.auto
  37. lftp -f /root/fxp.auto

  38. # Do clean the tmp files
  39. rm -f /root/lftp.auto
  40. rm -f /root/fxp.auto
复制代码


还没写完,最近比较忙,所以先写一个粗稿在这里,等考试完了之后慢慢改进。基本上是利用lftp可以使用文件进行自动操作和它的mirror指令来做的。
回复 支持 反对

使用道具 举报

发表于 2005-4-15 07:31:19 | 显示全部楼层
我写的镜像Cygwin的script,根据网上的源码改的,可以一个一个文件下载,你应该可以实现边下载,边导出的.

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

发表于 2005-4-15 09:49:04 | 显示全部楼层
怎么这么长啊!
回复 支持 反对

使用道具 举报

发表于 2005-4-17 02:01:31 | 显示全部楼层
bash……不大会,不过看上去好像不是很长啊,主要是注释比较多吧
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表