Simple command line chat feature of netcat
- 2023年1月31日
- 技術情報
Today, I would like to share about using netcat to send messages. Let’s take a look.
Netcat is a command line utility tool for performing operations about TCP or UDP and also known as a powerful networking tool. It is mostly used for port scanning, transfering data and troubleshooting a server but in this blog, I will share just about messaging using netcat.
You can install netcat by the following command in debian based operating systems. You will find other installation methods for other operating systems by googling.
sudo apt-get install netcat
To create a messaging service with netcat, run the following command in the terminal to listen on a port of the server.
// Ross
nc -lvp 2000
And on the other system, run the following command to connect the chat server.
// Rachel
nc {ip_of_Ross} 2000
Now Ross and Rachel can send message to each other.
But the messaging style is so simple that can’t know obviously who sent the message. For that, you can add prepending name to the chat by using mawk.
// Ross
mawk -W interactive '$0="Ross: "$0' | nc -l -v -p 2000
// Rachel
mawk -W interactive '$0="Rachel: "$0' | nc {ip_of_Ross} 2000
There we go. It is cool, isn’t it.
For details of ‘nc’ usage, run ‘man nc’ in terminal.
This is all for now. Hope you enjoy that.
By Asahi
waithaw at 2023年01月31日 10:00:00