0

I'm disabling Ctrl-Alt-Del on a RHEL6 server and enabling Alt-SysRq.

In the /etc/init/control-alt-delete.conf file I have commented out the exec /sbin/shutdown -r now "Control-Alt-Delete pressed" line and replaced it with exec /bin/echo "Control-Alt-Delete has been disabled by the administrator." >/dev/console.

Unfortunately, this leaves the message hanging on a command prompt instead displaying the message and then dropping to a new prompt. I've tried /bin/echo -e and added a newline at the end of the string, but that still won't present a new prompt after displaying the message.

I've tried using >&1 to simply send the message to STDOUT, but that does not display anything at all.

A simple solution would be to add text indicating that the user needs to press Enter to return to a prompt, but I'd prefer this happen on its own.

How do I echo a message and then return to a prompt?

4

You don't. The decision to display a new prompt is up to the shell. And the shell doesn't know anything about what you've echoed to /dev/console.

What you could do is try to find which TTY is the currently active one (maybe with fgconsole?) and send SIGINT to the bash in that TTY. That has the same effect as hitting ^C in that terminal.

  • Then if I don't go the route of echoing to /dev/console, how do I do this? Surely there must be a way. – theillien May 21 '14 at 22:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.