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/

相关文章:

objective-c - 在 ARC 中获取 FSPathCopyObjectAsync 的回调

macos - docker-machine 在 `DBG | Filling zeroes` 处创建中断

python - Conda:创建虚拟环境

linux - 如何在 bash 中使用 && 和 grep

linux - 用于从文件名中删除空格的 Bash 脚本

linux - 创建同名文件和目录

linux - 无法分离 screen session

linux - OpenLDAP 安装 - 为 LDIF 构建配置

linux - 在具有 tar.uue 扩展名的 linux 上安装工具

python - timeout_decorator - 是否可以禁用或使其在 Windows 上工作?