linux - bash 脚本 Heredoc + FTP 错误

标签 linux macos bash shell heredoc

我试着这样做

 #!/bin/bash

 ftp "$HOST"$3"/"$2"/" <<EOD
        #toggle Interactive mode
        prompt off
        lcd $5"/"$4
        mget "$4"*
        exit
 EOD

出现以下错误

syntax error: unexpected end of file

当我将其更改为或任何其他可能性时

ftp "$HOST"$3"/"$2"/" <<<EOD
            #toggle Interactive mode
            prompt off
            lcd $5"/"$4
            mget "$4"*
            exit
     EOD

我明白了

./download.sh: line 31: 87621 Segmentation fault: 11  ftp "$HOST"$3"/"$2"/" <<< EOD
./download.sh: line 20: prompt: command not found
./download.sh: line 21: lcd: command not found
./download.sh: line 22: mget: command not found

我不确定如何解决这个问题。我该怎么办 O_O

最佳答案

在我的 Mac 上,段错误是由脚本中的注释产生的。删除尾随 # 的行将使其工作。

关于linux - bash 脚本 Heredoc + FTP 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18085297/

相关文章:

linux - 无法使用新创建的帐户连接到 FTP

linux - 什么是 $HOME/.lvm

macos - 在 JavaScript for Automation (OSA) 中使用 Application.currentApplication() 时出错

c - 苹果操作系统 "configure: error: cannot run C compiled programs"

bash - 为什么 awk 将指数转换为普通整数?

bash - 我需要一些关于 SRT 字幕文本处理的想法

linux - 将html转换为图像的程序

swift - 为 shell 命令获取实用程序的完整路径,如 7zip 等

linux - 如何将 bash 别名添加到 .bashrc 以接受参数?

linux - 内部脚本和样式表总是指向索引文件 (Node.JS)