使用systemctl或service命令未在CentOS7中提示用户输入 [英] User input is not promted in CentOS7 using systemctl or service command

查看:289
本文介绍了使用systemctl或service命令未在CentOS7中提示用户输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正在尝试使用systemctl或service命令停止系统服务。命令如下:

Am trying to stop the system service using systemctl or service command. 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
}

在CentOS 6中使用service命令运行了相同的命令,并在控制台和输入了输入。有人可以建议我是否错过了此处要提示的内容,或者我们如何使用systemctl提示用户输入。

The same ran in CentOS 6 using service command, its displayed on console and entered the input. Can anyone please suggest me that am I missed something here to prompt or how we can prompt the user input using systemctl.

推荐答案

最后,知道如何在CentOS 7中从用户读取密码。这是命令。

Finally, come to know that how to read password from user in CentOS 7. This is the command.

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

systemd-ask-password —查询用户输入系统密码

systemd-ask-password — Query the user for a system password

这篇关于使用systemctl或service命令未在CentOS7中提示用户输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆