diff --git a/MP1/scripts/grepp.py b/MP1/scripts/grepp.py new file mode 100644 index 0000000..01656c2 --- /dev/null +++ b/MP1/scripts/grepp.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +import socket + +PORT = 5055 +ALL_IPS = [ + "172.22.156.3", + "172.22.158.2", + "172.22.94.2", + "172.22.156.4", + "172.22.158.3", + "172.22.94.3", + "172.22.156.5", + "172.22.158.4", + "172.22.94.4", + "172.22.156.6" +] + +def grep_all_ips(ips): + for ip in ips: + try: + client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + client_socket.connect((ip, PORT)) + print(f"Connected to server at {ip}:{PORT}") + + client_socket.sendall("ls -la".encode()) + data = client_socket.recv(65536) + print("Received:", data.decode()) + except Exception as e: + print(f"Failed to connect to {ip}:{PORT} - {e}") + finally: + client_socket.close() + +grep_all_ips(ALL_IPS) \ No newline at end of file diff --git a/MP1/scripts/install_cmd.sh b/MP1/scripts/install_cmd.sh new file mode 100644 index 0000000..c9f9224 --- /dev/null +++ b/MP1/scripts/install_cmd.sh @@ -0,0 +1,6 @@ +chmod +x grepp.py +mkidr -p ~/bin +cp grepp.py ~/bin/grepp +chmod +x ~/bin/grepp +export PATH="$HOME/bin:$PATH" +course ~/.bashrc \ No newline at end of file