primero iremos al “home” y ahí con el root crearemos dos archivos, chatusers.txt, y chatusers.py
import sys
print(input(f"> {sys.argv[1]}: "))
luego con root daremos permisos a otros con
chmod o=rw chatusers.txt
chmod 777 chatusers.py
luego en cada usuario abriendo su .bashrc escribiremos como alias:
aliaschat='cat /home/chatusers.txt'aliasmsg_chat='python3 /home/chatusers.py "$(whoami)" | tee -a /home/chatusers.txt'
otra opción podría ser:
msg_chat() {
python3 /home/chatusers.py "$(whoami)" | tee -a /home/chatusers.txt
}
una vez hecho eso usaremos "~$ bash " para que se actualicen los cambios de la bash.
luego entraremos a nuestros usuarios y podremos poner el comando
chat
para poder ver el chat completo de los demás usuarios, y el comando
msg_chat
para poder enviar un mensaje con nuestro usuario
el resultado sería así:
alexander@DESKTOP-N05VNAV:~$ chat
> alexander: holaa, hay alguien?
> testuser: ok
alexander@DESKTOP-N05VNAV:~$ msg_chat
> alexander: hola mi nombre esta ahi
hola mi nombre esta ahi
alexander@DESKTOP-N05VNAV:~$ su testuser
Password:
testuser@DESKTOP-N05VNAV:/home/alexander$ chat
> alexander: holaa, hay alguien?
> testuser: ok
> alexander: hola mi nombre esta ahi
testuser@DESKTOP-N05VNAV:/home/alexander$ msg_chat
> testuser: si, ya ví xddd, weno y a seguir aprendiendo
si, ya ví xddd, weno y a seguir aprendiendo
testuser@DESKTOP-N05VNAV:/home/alexander$ chat
> alexander: holaa, hay alguien?
> testuser: ok
> alexander: hola mi nombre esta ahi
> testuser: si, ya ví xddd, weno y a seguir aprendiendo
testuser@DESKTOP-N05VNAV:/home/alexander$