简体   繁体   English

使用systemctl或service命令未在CentOS7中提示用户输入

[英]User input is not promted in CentOS7 using systemctl or service command

Am trying to stop the system service using systemctl or service command. 我正在尝试使用systemctl或service命令停止系统服务。 The command as follows 命令如下

systemctl start service_name or service service_name start

In that stop method am asking user to enter password which is not display on console(Suspecting ran in background). 在该停止方法中,要求用户输入未在控制台上显示的密码(怀疑在后台运行)。 Stop method as follows 停止方法如下

stop() {
read -s -p "Please provide password to stop the service" passwd
}

The same ran in CentOS 6 using service command, its displayed on console and entered the input. 在CentOS 6中使用service命令运行了相同的命令,它显示在控制台上并输入了输入。 Can anyone please suggest me that am I missed something here to prompt or how we can prompt the user input using systemctl. 任何人都可以建议我是否错过了此处要提示的内容,或者我们如何使用systemctl提示用户输入。

Finally, come to know that how to read password from user in CentOS 7. This is the command. 最后,了解如何在CentOS 7中从用户读取密码。这是命令。

pwd=`systemd-ask-password --no-tty "Please enter admin password "`

systemd-ask-password — Query the user for a system password systemd-ask-password —向用户查询系统密码

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

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