IT Projects

This page will be dedicated to various IT projects. Not sure about layout etc yet

Python - systemmonitoring-test

First part of a python script for uni course


import systemmonitoring

# for-loop to get address as well as port
for address, port in [("www.his.se", 80), ("142.250.74.174", 80), ("127.0.0.53", 80)]:
    resultofprobing = systemmonitoring.probetcpport(address, port)

    print("Probing", address, "on port", port)

    # if a connection, based on "systemmonitoring.py", is a success, print this
    if resultofprobing == True:
        print("probing", address, "on port", port, "success")

    # if a connection, based on "systemmonitoring.py", failed, print this
    elif resultofprobing == False:
        print("probing", address, "on port", port, "fail")
    

Python - systemmonitoring

Second part of a python script for uni course


import socket

# based on systemmonitoring-test, connects to address and port
      
def probetcpport(address, portnumber):
    try:
        socket.create_connection((address, portnumber))
        return True
    except:
        return False
    

Python - regex

A simple Python script for uni course.



from ast import Break
import re

def lookslikelogin(input):
    if(len(input) != 8):
        return False

    regex = "[a][0-9][0-9][a-z]{5}"

    isamatch = re.search(regex, input)

    if(isamatch):
        return True
    else:
        return False

while True:
    print("entry login name: ", )
    userinput = input()
    if(userinput == ""):
        break
    if(lookslikelogin(userinput.strip()) == False):
        print("input '", userinput.strip(),
              "' does not look like a student login :(")
    elif(lookslikelogin(userinput.strip())):
        print("input '", userinput.strip(), "' looks like a student login :)")