简体   繁体   English

理解意外标记“换行符”附近的语法错误

[英]understanding syntax error near unexpected token `newline'

I'm trying to follow this answer , which suggesting running this command:我正在尝试遵循这个答案,它建议运行这个命令:

sudo bash -c "echo -n | openssl s_client -showcerts -connect $hostname:$port -servername $hostname \
    2>/dev/null  | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p'  \
    >> $trust_cert_file_location"

But I'm getting:但我得到:

syntax error near unexpected token `newline'意外标记“换行符”附近的语法错误

Now, I've figured out that it's probably because of either the > or >> operators in the command.现在,我发现这可能是因为命令中的 > 或 >> 运算符。 I've found answers saying to escape such characters with quotes, but they all talk about cases when the '>' characters are a part of a simple text.我发现答案说用引号转义这些字符,但他们都谈论'>'字符是简单文本的一部分的情况。 What to do when it's an actual operator like in my case?当它是像我这样的实际操作员时该怎么办?

Assuming you are coping some white spaces after the \ .假设您在\之后处理一些空格。

Suggesting to remove the new line separator:建议删除新的行分隔符:

 sudo bash -c "echo -n | openssl s_client -showcerts -connect $hostname:$port -servername $hostname 2>/dev/null  | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p'  >> $trust_cert_file_location"

Suggesting to test if you get all certificates or just the first one.建议测试您是否获得所有证书或仅获得第一个证书。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM