Don’t want to read the blog? Here is the source code:
Problem Statement
In my pre-cloud day-to-day work, I always need the check whether port access to a server is open on not. The usual way to do this is telnet. But many times, the list of server-port could get huge, and checking each individually was taking a lot of effort. Hence this tool.
Information
This code is packaged into a .exe and hence can run standalone (check tools folder).
Please verify if you have the following:
- exe: port_checker.exe
2. file: input/in_server_port.csv
Example of input for your in_server_port.csv file. Please don’t change the header name.
Source Code available in src/ folder. Please only use it if you want to change the script. The .exe is a standalone executable.
Usage
- Download the tools folders.
- Change the input file as mentioned above.
- Open the command prompt and run the below command:
port_checker.exe
Output
References
FAQ
- I am scared of .exe. Hope it is not a virus.
A: It is not. If you are worried about it, please download the src folder and use the python script. The exe is to make it easy for people without Python coding knowledge.
- Why is the exe so big?
A: It has to do with how Python creates the package. Since the .exe should run standalone on your machine, python bundles all the dependencies into it. This includes modules like NumPy, pandas, socket, etc. Hence the big file size.
- This can be done using simple shell or bat commands. Why use Python for this?
A: There are better ways to do it of course. But I am studying Python and hence this is just me solving my day-to-day problem using the language.
- How does will it take to run?
A: Depending on the number of entries you have in the input file, TCP socket connection can take some time. The code has a timeout set (40 seconds) for each entry. Usually, a socket connection is established but failed long before it.