danionescu0 / docker-flask-mongodb-example

Uses docker compose with a python flask microservice and MongoDB instance to make a sample application
GNU General Public License v3.0
99 stars 41 forks source link

check for open ports with script #46

Closed neelabalan closed 3 years ago

neelabalan commented 3 years ago

I have written a small script to check for open ports. Let me know if I can create a PR for this

#!/bin/bash
arr=("$@")
   for i in "${arr[@]}";
      do
          echo "$i"
      done
isopenport()
{
    arr=("$@")
    for i in "${arr[@]}";
        do
            nc -z 127.0.0.1 $i &> /dev/null
            result1=$?
            if [  "$result1" != 0 ]; then
                echo  port $i is free 
            else
                echo port $i is used  
            fi
        done
}
ports=(80 81 82 83 84 85 86 88 1883 27017 8080 3000)

isopenport "${ports[@]}" 
danionescu0 commented 3 years ago

It looks nice, i've tested it on my linux and it works. You can create a PR and i'll update the documentation. I was thinking it would sit on root folder, maybe with a suggestive name. Thanks!

neelabalan commented 3 years ago

Thanks. I will place the script in the root folder.

neelabalan commented 3 years ago

shall I close this issue?