1

Is there a way to send a message to a remote terminal similar to using the wall command for other users on the local system? In this scenario I want to specify a username@hostname and have a message appear in their terminal if they are logged in.

Mike
  • 11
  • 1
  • 2

2 Answers2

6

You can use the write command to send messages to a specific user instead of to everybody. You can send them over the network using whatever login credentials you already have, usually over ssh like this: ssh youruse@hostname write username to send username@hostname a message.

Caleb
  • 11,583
  • 4
  • 35
  • 49
  • this opens up a connection to write message to the user, and I have to manually close the connection . How can I just open up a conncetion, send the message and close it. I want to write this inside a bash script – Eular Jul 19 '21 at 16:09
  • @Eular The same way you do for *any* STDIN stream in a shell. You can type a message and end it with CTRL-D, or pipe content to the command: `echo foo | ssh ...`. – Caleb Jul 21 '21 at 07:42
1

you can use nc for example in receiving host type nc -l port_number and in sending host type nc ip port_number like

nc -l 3106

in receiving host and

nc 192.168.32.98 3106

in sending host for me that worked