Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #create controlpc.py with slave.py
- # python3 slave.py codes
- ##create slave.py with python3 controlpc.py
- #import time
- #import socket
- #import sys
- #import os
- # Initialize s to socket
- #s = socket.socket()
- # Initialize the host
- #host = "127.0.0.1"
- # Initialize the port
- #port = 8080
- # bind the socket with port and host
- #s.connect((host, port))
- #print("Connected to Server.")
- # receive the command from master program
- #command = s.recv(1024)
- #command = command.decode()
- # match the command and execute it on slave system
- #if command == "open":
- # print("Command is :", command)
- # s.send("Command received".encode())
- # you can give batch file as input here
- # os.system('ls')
- import time
- import socket
- import sys
- import os
- # Initialize s to socket
- s = socket.socket()
- # Initialize the host
- host = socket.gethostname()
- # Initialize the port
- port = 8080
- # Bind the socket with port and host
- s.bind(('', port))
- print("waiting for connections...")
- # listening for connections
- s.listen()
- # accepting the incoming connections
- conn, addr = s.accept()
- print(addr, "is connected to server")
- # take command as input
- command = input(str("Enter Command :"))
- conn.send(command.encode())
- print("Command has been sent successfully.")
- # receive the confirmation
- data = conn.recv(1024)
- if data:
- print("command received and executed successfully.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement