免费注册 查看新帖 |

Chinaunix

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

自动ftp和case语句一起怎么用? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-06-23 10:36 |只看该作者 |倒序浏览
#!/bin/sh

echo "which file do you want to download"
read file

case $file in
        log1)
        ftp -vin 10.1.1.1 <<!
        user sys admin
        cd /var/log
        bin
        hash
        get log1
        by
        !
;;
        log2)
        ftp -vin 10.1.1.1 <<!
        user sys admin
        cd /var/message
        bin
        hash
        get log2
        by
        !
;;
esac
#########################################


执行:
which file do you want to download
log1
ftp.sh: syntax error at line 28: `end of file' unexpected

不知道哪里出错了呢?

论坛徽章:
8
摩羯座
日期:2014-11-26 18:59:452015亚冠之浦和红钻
日期:2015-06-23 19:10:532015亚冠之西悉尼流浪者
日期:2015-08-21 08:40:5815-16赛季CBA联赛之山东
日期:2016-01-31 18:25:0515-16赛季CBA联赛之四川
日期:2016-02-16 16:08:30程序设计版块每日发帖之星
日期:2016-06-29 06:20:002017金鸡报晓
日期:2017-01-10 15:19:5615-16赛季CBA联赛之佛山
日期:2017-02-27 20:41:19
2 [报告]
发表于 2008-06-23 10:41 |只看该作者
ftp -vin 10.1.1.1 <<!
        user sys admin
        cd /var/log
        bin
        hash
        get log1
        by
!



   Here Documents
       This type of redirection instructs the shell to read  input  from  the
       current  source  until  a  line containing only word (with no trailing
       blanks) is seen
.  All of the lines read up to that point are then used
       as the standard input for a command.

       The format of here-documents is:

              <<[-]word
                      here-document
              delimiter

论坛徽章:
11
金牛座
日期:2015-03-19 16:56:22数据库技术版块每日发帖之星
日期:2016-08-02 06:20:00数据库技术版块每日发帖之星
日期:2016-04-24 06:20:00数据库技术版块每日发帖之星
日期:2016-04-13 06:20:00IT运维版块每日发帖之星
日期:2016-04-13 06:20:00数据库技术版块每日发帖之星
日期:2016-02-03 06:20:00数据库技术版块每日发帖之星
日期:2015-08-06 06:20:00季节之章:春
日期:2015-03-27 15:54:57羊年新春福章
日期:2015-03-27 15:54:37戌狗
日期:2015-03-19 16:56:41数据库技术版块每日发帖之星
日期:2016-08-18 06:20:00
3 [报告]
发表于 2008-06-23 10:44 |只看该作者
!请顶格写~~

论坛徽章:
0
4 [报告]
发表于 2008-06-23 10:58 |只看该作者
thanks.....:wink:

论坛徽章:
0
5 [报告]
发表于 2008-06-23 11:14 |只看该作者
有个性,用!写Here doc :)
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP