首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Bash脚本通过FTP上传文件

Bash脚本通过FTP上传文件
EN

Stack Overflow用户
提问于 2015-08-20 16:00:49
回答 1查看 1.4K关注 0票数 0

我正在尝试这个脚本来创建文件并上传到ftp服务器。该脚本是基于在论坛上看到的其他脚本。

代码语言:javascript
复制
    HOST=example.com #This is the FTP servers host or IP address.
    USER=ftpuser #This is the FTP user that has access to the server.
    PASS=1234 #This is the password for the FTP user.
    FILE_PREFIX=FRAME

    timestamp() {
      date +"%s"
    }

    ftp() {
        ftp -i -n $HOST << END_SCRIPT
        user $USER $PASS
        # #cd /path/to/file
        put $FILENAME
        bye

    END_SCRIPT
    }

    # # Call 1. Uses the ftp command with the -inv switches. 
    # #-i turns off interactive prompting. 
    # #-n Restrains FTP from attempting the auto-login feature. 
    # #-v enables verbose and progress. 


    # shoot picture

    while true; do
        FILENAME=${FILE_PREFIX}_$(timestamp).txt
        echo $FILENAME > $FILENAME

        echo "Subiendo $FILENAME"
        ftp

        sleep 2
    done
    EOF

当我执行脚本时,我会收到以下错误消息:

script.sh: 14: script.sh: 0:打开的文件太多

你能帮我解决这个错误吗?谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-08-20 16:11:30

将函数ftp重命名为其他内容,并在使用sleep 2之前调用它。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32123022

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档