了解语法错误接近意外的令牌`newline'

发布于 2025-01-29 08:15:11 字数 685 浏览 1 评论 0原文

我正在尝试关注 21181447”> 21181447>这个答案暗示运行此命令:

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"

但是我得到了:

语法错误接近意外的令牌`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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

原谅我要高飞 2025-02-05 08:15:12

假设您要在\之后应对一些白色空间。

建议删除新的行分隔符:

 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"

建议测试您是否获得所有证书或第一个证书。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文