search for a port number
I find myself doing google everytime I want to search for port number mapping. So, here is a short script to do just that π
#!/bin/bash - #=============================================================================== # # FILE: portfind.sh # # USAGE: ./portfind.sh # # DESCRIPTION: # # OPTIONS: --- # REQUIREMENTS: --- # BUGS: --- # NOTES: --- # AUTHOR: Amit Agarwal (aka), # ORGANIZATION: # CREATED: 08/29/2017 19:00 # Last modified: Tue Aug 29, 2017 07:00PM # REVISION: --- #=============================================================================== set -o nounset # Treat unset variables as an error #This is the directory where you have mappings file downloaded ODIR=/root ofile=$ODIR/service-names-port-numbers.xml if [[ ! -f "$ofile" ]] then wget http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xml -O "$ofile" fi which xmlstarlet >/dev/null 2>&1 if [[ $? == 0 ]] then echo "xmlstarlet is installed" else apt-get install xmlstarlet fi #### xmlstarlet el -u service-names-port-numbers.xml ## registry/record - protocol and number proto=${2:-tcp} port=${1:-21} (echo '';sed '1,4d' $ofile) |xmlstarlet sel -t -m "//record[protocol='$proto'][number=$port]" -o "Number(Protocol): " -v number -o '(' -v protocol -o ')' -n -o "Description :" -v description -n
Related Articles:
- 2013/10/10 Check all vim colorschemes for minor issues
- 2013/10/04 Home grown mail scheduler with bash script and cron
- 2013/08/16 Delete all but some directories
- 2013/05/06 Manage your servers the easy way with perl script over ssh with no remote client.
- 2012/12/28 Disable a few cores when you want to save power.
Authored By Amit Agarwal
Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.