&quot“回声密码| sudo -s&quot带有感叹号

发布于 2025-02-13 20:40:49 字数 279 浏览 0 评论 0原文

我想做的是

$ echo密码!P | sudo -s [命令]

Linux终端中的 (在我的情况下,Ubuntu20.04)。如果按原样键入它,则感叹号将参考命令行的历史记录,如果!p = pwd,它将是诸如passwordpwd之类的字符串,并且不会正确发送密码!p。我已经尝试了各种方法来逃脱感叹号,例如“密码!p”,“密码!p”,“ password!p'\''等。最后一个行为与'echo |相同。 '但没有导致使用该命令。有什么方法可以解决吗?

What I want to do is

$ echo password!p | sudo -S [command]

in a linux terminal (in my case, ubuntu20.04). If you type it as it is, the exclamation mark will refer to the history of the command line, and if !p=pwd, it will be a string like passwordpwd and will not send the password!p correctly. I have tried every way I could find to escape the exclamation, like 'password!p', 'password!p', '\''password!p'\'', etc. The last one behaves the same as 'echo |' but did not result in using the command. Is there any way to get through this?

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

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

发布评论

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

评论(1

魔法唧唧 2025-02-20 20:40:49

可以尝试关闭历史扩展。

set +o histexpand
echo -n "password!p" | sudo -S command
set -o histexpand # if you want to restore the capability after

Could try turning off history expansion.

set +o histexpand
echo -n "password!p" | sudo -S command
set -o histexpand # if you want to restore the capability after
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文