免费注册 查看新帖 |

Chinaunix

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

[系统管理] FTP脚本求助 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-08-27 00:16 |只看该作者 |倒序浏览
大家好,情景:solaris终端机FTP到某一个网段10多台solaris服务器上的相同目录抓取2个文件,且每个服务器的这两个文件名相同;需求:在终端机上自动建立这10多台服务器Hostname的文件夹,且将各自服务器文件ftp到对应的目录。请大家提供下思路,有现成脚本更好。谢谢大家!

论坛徽章:
15
2015年辞旧岁徽章
日期:2015-03-03 16:54:15双鱼座
日期:2015-01-15 17:29:44午马
日期:2015-01-06 17:06:51子鼠
日期:2014-11-24 10:11:13寅虎
日期:2014-08-18 07:10:55酉鸡
日期:2014-04-02 12:24:51双子座
日期:2014-04-02 12:19:44天秤座
日期:2014-03-17 11:43:36亥猪
日期:2014-03-13 08:13:51未羊
日期:2014-03-11 12:42:03白羊座
日期:2013-11-20 10:15:18CU大牛徽章
日期:2013-04-17 11:48:45
2 [报告]
发表于 2013-08-27 06:45 |只看该作者
本帖最后由 rdcwayx 于 2013-08-27 08:45 编辑
  1. HOST='ftp.users.net'
  2. USER='yourid'
  3. PASSWD='yourpw'
  4. FILE='file.txt'

  5. for HOST in server1 server2 serverx ....
  6. do
  7.   #FTP
  8. ftp $HOST <<END_SCRIPT
  9. user $USER
  10. $PASSWD
  11. put $FILE
  12. quit
  13. END_SCRIPT

  14. done
复制代码

求职 : Linux运维
论坛徽章:
3
戌狗
日期:2015-01-11 13:27:532015年辞旧岁徽章
日期:2015-03-03 16:54:152015年亚洲杯纪念徽章
日期:2015-05-08 15:03:30
3 [报告]
发表于 2013-08-27 11:28 |只看该作者
#!/bin/bash

usr="xx";#user
pwd="xx";#password
get_file="xx";#file
ip_file="ip.list"#server ip list

expect <<EOF
set timeout 3
set list_ip [open $ip_file r]
while {[gets \$list_ip ip ] != -1} {
exec mkdir \$ip
spawn ftp \$ip
expect "Name"
send "$usr\r"
expect "*ssword"
send "$pwd\r"
expect "ftp>"
send "cd dir\r"
expect "ftp>"
send "get $get_file \$ip/$get_file \r"
expect "ftp>"
send "quit\r"
}
expect eof
EOF

求职 : Linux运维
论坛徽章:
3
戌狗
日期:2015-01-11 13:27:532015年辞旧岁徽章
日期:2015-03-03 16:54:152015年亚洲杯纪念徽章
日期:2015-05-08 15:03:30
4 [报告]
发表于 2013-08-27 11:28 |只看该作者
  1. #!/bin/bash

  2. usr="xx";#user
  3. pwd="xx";#password
  4. get_file="xx";#file
  5. ip_file="ip.list"#server ip list

  6. expect <<EOF
  7. set timeout 3
  8. set list_ip [open $ip_file r]
  9. while {[gets \$list_ip ip ] != -1} {
  10. exec mkdir \$ip
  11. spawn ftp \$ip
  12. expect "Name"
  13. send "$usr\r"
  14. expect "*ssword"
  15. send "$pwd\r"
  16. expect "ftp>"
  17. send "cd dir\r"
  18. expect "ftp>"
  19. send "get $get_file \$ip/$get_file \r"
  20. expect "ftp>"
  21. send "quit\r"
  22. }
  23. expect eof
  24. EOF
复制代码

论坛徽章:
0
5 [报告]
发表于 2013-08-27 15:55 |只看该作者
  1. ftp -niv <<END
  2. open HOST
  3. user xxx xxxx
  4. binary y
  5. lcd /xxxx
  6. put xxx.txt
  7. close
  8. END
  9. ftp -niv <<END
  10. open HOST
  11. user xxx xxxx
  12. binary y
  13. lcd /xxxx
  14. put xxx.txt
  15. close
  16. END

  17. ...........................
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP