加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

如何在Emacs中运行sudo命令?

发布时间:2020-12-15 18:44:52 所属栏目:安全 来源:网络整理
导读:我正在尝试为一些常用的sudo shell命令创建快捷键(例如,C-c的运行(shell命令“sudo /etc/init.d/apache2 restart”)). 我尝试使用如上所述的直接shell命令调用,但它只是输出以下内容到* Shell命令输出*缓冲区: [sudo] password for Inaimathi:Sorry,try aga
我正在尝试为一些常用的sudo shell命令创建快捷键(例如,C-c的运行(shell命令“sudo /etc/init.d/apache2 restart”)).

我尝试使用如上所述的直接shell命令调用,但它只是输出以下内容到* Shell命令输出*缓冲区:

[sudo] password for Inaimathi:
Sorry,try again.
[sudo] password for Inaimathi:
Sorry,try again.
sudo: 3 incorrect password attempts

实际上并不要求输入密码.我不想使用sudo emacs启动Emacs,但是如果没有其他工作,我想这是一个选择.

理想的解决方案将是Emacs内的一个功能(而不是操作系统的诡计更改shell或sudo命令的行为). (sudo-shell-command“dostuff”)或(with-password-prompt(shell-command“sudo dostuff”)).

怎么样:
(shell-command (concat "echo " (shell-quote-argument (read-passwd "Password? "))
                       " | sudo -S your_command_here"))

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读