Skip to content

Instantly share code, notes, and snippets.

View SudhenduP's full-sized avatar
🏠
Working from home

Sudhendu SudhenduP

🏠
Working from home
View GitHub Profile
@SudhenduP
SudhenduP / character_input.py
Created September 18, 2016 05:35
Solutions for practicepython dog org
import datetime
get = datetime.datetime.now()
currYear = get.year
uname = raw_input('Please enter your name: ')
age = input('Please enter your age: ')
print'Hi ', uname,'. Your age is', age
num1 = input('Please enter the number')
num2 = input('Even the divisor')
if num1%2 == 0:
print'Number is even'
else:
print'Number is odd'
if num1%4 == 0:
@SudhenduP
SudhenduP / divisors.py
Created September 18, 2016 07:10
Create a program that asks the user for a number and then prints out a list of all the divisors of that number
num1 = input('Enter a number for which you want to check the divisor')
dataset = range(1, num1)
print dataset
for data in dataset:
if num1%data == 0:
print data
N,S,I,R,b,k
550,500,50,0.5,0.007
IP Port
10.158.102.36 3389
google.com 8777
localhost 80
IP Port Status
10.158.102.36 3389 Connection to 10.158.102.36 on port 3389 failed: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
google.com 8777 Connection to google.com on port 8777 failed: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
localhost 80 Connected to localhost on port 80
import socket
import sys
import pandas as pd
import os
def get_checklist(severportfile):
#port_checklist = pd.read_csv(r'C:\Users\Sudhendu-BCT\Python_Practice\PortChecker\check_port_list.csv')
port_checklist = pd.read_csv(input_file)
port_checklist.insert(loc=2,column="Status",value = '')
return port_checklist
def check_server(address, port):
# Create a TCP socket
timeout = 40 #timeout in seconds
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#s.settimeout(timeout)
print ("Attempting to connect to %s on port %s" % (address, port))
try:
s.connect((address, port))
#print ("Connected to %s on port %s" % (address, port))
def check_create_status(severportfile):
print ('Reading from files: ' +severportfile)
get_file= get_checklist(severportfile)
for i in range(len(get_file)) :
print("Started Processing")
address = get_file.loc[i, "IP"]
port = get_file.loc[i, "Port"]
check = check_server(address, port)