Final Task Solution
- script1.py allows users to upload a file from the command line to a specified IP address and port and recieve the output of file command from script2.py.
- Uses the socket module to establish a TCP connection with the server.
- Checks if the specified file exists on the client-side.
- Sends the filename to the server.
- Sends a start-of-transfer message to indicate the beginning of file transfer.
- Reads the file in chunks and sends them over the socket.
- Sends an end-of-transfer message to indicate the completion of file transfer.
- Receives the output of a command executed on the file from the server.
- Prints the received output in JSON format.
- Uses the socket module to listen for incoming connections from clients.
- Receives the filename and file data from the client.
- Saves the received file to a "received" folder on the server.
- Constructs and executes a specified command on the received file using the subprocess module.
- Sends the output of the command back to the client in JSON format.
- Python3 needs to be installed.
script2.py needs to run first as it will wait for conenction and file from script1.py
python script2.py
script1.py requires the file path, the address to send to and the port.
python script1.py <file_path> <host> <port>