Python for Linux Admins – Part V

In fifth part of our Python blog entry i will write my own script.

This script will provide us with the port information of any Linux service.

Also you will see a touch of socket programming in python. Enjoy !

I have named this script as porter.

#!/usr/bin/env python

#program for port info by Hyperi0n

print ” Porter ver 0.1 Created by Hyp3ri0n www.itpings.com”

import socket
import time

I = raw_input (‘Please enter the service name’)

print ” You Typed”, I

p = socket.getservbyname(I)

print “port of this Service is”, p

time.sleep(2)

print “………………”

#End

Enjoy !

Please Comment ” It makes me feel alive”

Thanks,

Salman Aftab