28

I am trying to find a way to send a message (like a popup message) from 1 PC to another. both are using Ubuntu. Already tried the smbclient way but this only works between a linux PC to a windows PC. I need a way to send messages from an Ubuntu PC to another Ubuntu PC. Similar to the way of Windows Net Send.

  • notify-send sends a pop up on my terminal but I wanted to send a popup to other users (may be a list of specific users) but without using sudo or ssh , do I have any alternative .A command which works as "notify-send" but to send message on other user terminal. – user510910 Feb 24 '16 at 11:09
27

Install ssh and libnotify-bin (via terminal):

sudo apt-get install ssh libnotify-bin

on both computers.

(You may have libnotify-bin installed already. Mine had it already.)

Then SSH (via the terminal) into the other computer:

ssh <user name>@<ip address>

And then when you're logged in, type:

export DISPLAY=:0
notify-send "Title of message" "message text"

Happy message-sending!
(or scaring XD)

  • 1
    Even though this is a very intelligent answer am trying to find a way to send it without ssh. With the ssh option i already know it works (using wall for example) but your notify-send is very smart. – Luis Alvarado Mar 23 '11 at 1:34
  • 1
    After searching several methods this one is the best. Because of 2 reasons: 1. ssh gives me some security over doing this and 2. The use of DISPLAY allows to select to which video the message will show. I tested using ssh user@ip/domain 'DISPLAY=:0 notify-send "TITLE" "MESSAGE"' – Luis Alvarado Apr 5 '11 at 17:00
  • It may work in a home enviorment, but in a large organisation, i am not sure if it is possible to install SSH on every client system, I have experience as in my office there are about 100 coms, there should be another way to send a message with out installing SSh – The_skinny_man Oct 26 '11 at 5:25
  • Check out my answer for accomplishing this without ssh! :) – Matt Oct 26 '11 at 6:05
31

I read you wanted to do this without SSH, I believe I have a solution: netcat [nc] It comes with Ubuntu by default.

First we need a "daemon" to run in the background. Second, we need a program to make the alert pop up. I have zenity installed. If you do not, please install it, or edit the script to use whatever you like [e.x. xmessage, but that is ugly]. Next, paste this into 'daemon.sh':

#!/bin/bash
port=3333
nc -l $port | while read msg; do zenity --info --text "$msg"; done

Now, make it executable chmod +x daemon.sh, now run it in the background: ./daemon.sh &

Now you're done! Well, you actually need to do this on each computer. You also will want to automate the start of the daemon. Open the 'startup' applications from the menu, and add your script. Once that's done, to send a message to the other computer, type in:

nc 192.168.1.X 3333 then type your message and hit Enter. Each enter line will make a message pop up. To exit nc, press Ctrl +C, or Ctrl +D.

Just make sure to replace 192.168.1.X with the real local IP of the other PC. [You can use ifconfig to find the IP address]

You could also make another script, say, message.sh. In that, paste:

#!/bin/bash
nc 192.168.2.X 3333

Then chmod +x message.sh. Then you can just type ./message.sh then type your message, then enter, and your message is sent. Also, now that I think of it, you could also add a sound notification. I would recommend mplayer, it's a CLI media player. Shouldn't be too hard to figure out, but if you have any questions, please don't hesitate to ask!

  • 1
    This is a neat solution, but I kinda prefer SSH because of security purposes. – ohitsanazn Nov 23 '11 at 2:08
  • 1
    Someone told me you can use socat instead of netcat, for SSL encryption. I never looked into it though. – Matt Nov 24 '11 at 0:06
  • 3
    Wow! nicely done! I changed it a bit to work with notify-osd: nc -l $port | while read msg; do notify-send "$HOSTNAME" "$msg" -i gtk-network; done – Khurshid Alam Jun 4 '13 at 14:50
  • Or with remote-connector ip address: while true; do nc -l -v 3333 2> status | while read msg; do ip=$(cat status | grep -o -P '(?<=from).*(?=port)') && notify-send "$ip" "$msg" -i gtk-network; done ; done – Khurshid Alam Jun 4 '13 at 22:21
  • You can use cryptcat to make your communication encrypted with a password. It works as same as nc – Anonymous Platypus Mar 17 '15 at 5:32
11

Use nc to send text between two computers on the same network (without encryption).

On the receiving computer do

nc -l 3333

On the sending computer do

nc 192.168.1.XX 3333

then just start typing and the text will show up on the other computer (after you press enter) until you hit ctlr+c.


You can get the IP of the receiving computer with hostname -I (run that on the receiving computer).

You don't have to use port 3333, use any number between 1025 and 65535 inclusive.

Remember that this is not encrypted. Any computer on your network can see what text you're transferring.

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.