System Scanner Tool

This is a python code to scan the system and print the username working directory, ip  address of user's device.

Code

import subprocess
user=subprocess.run(["whoami"], capture_output=True, text=True)
dire=subprocess.run(["pwd"], capture_output=True, text=True)
username=subprocess.run(["uname","-r"],capture_output=True, text=True)
ipad=subprocess.run(["ip","a"],capture_output=True,text=True)
o1=user.stdout
o2=dire.stdout
o3=username.stdout
print(f"Username: {o1}")
print(f"Directory: {o2}")
print(f"Kernel Version: {o3}")
o4=ipad.stdout
lines=o4.splitlines()
for line in lines:
    if "inet" in line and "scope global" in line:
        ip_address=line.strip().split()[1].split("/")[0]
        print(f"IP Address: {ip_address}")

Points to remember

  • To run this code i highly recommend Visual Studio Code.
  • You should have installed WSL on your windows.

Comments

Popular posts from this blog

Resonance Effect

Linux Fundamentals