Search This Blog

Monday, November 02, 2020

Python substitute for netcat

When working across multiple platforms and flavours of IX, a system administrator  might not always have tools like telnet or netcat available to test network connections. One tool that is on all flavours of IX and is universal is python.


A quick python script for testing network connection.

I used this python script to send a message via UDP to a logstash server.


import socket
message = 'Flah blah bleh'
byteToSend = str.encode(message)
serverAddressPort = ('IP Address', port)
bufferSize = 1024
soc = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM)
soc.sendto(byteToSend, serverAddressPort)