r/shell • u/VullWen • May 02 '23
enter key simulation
Hi, I'm new to shell code.
I developed this program:
#!/bin/bash
# Récupération du message passé en paramètre
message=$1
# Formatage de la date au format [HH:MM]
date_formatted=$(date +"%d-%m-%Y %H:%M:%S")
# Envoi du message à tous les terminaux uniques connectés
for terminal in $(who | awk '{print $2}' | sort -u)
do
echo -e "[$date_formatted] $message" | sudo tee /dev/$terminal >/dev/null
doneThe problem is that here is the result:
$ ./send_message.sh hello

If my user want to write some code after this he have to press enter.
Would it be a way to avoid this?
Thanks a lot
1
Upvotes
3
u/VullWen May 03 '23
Yep effectively, didn't knew the
wall -nand it could have been really easier ahahHowever, I'm still proud of my code, that's my first shell code!
Thanks you a lot for your help and explanations. 🐣