1

I want to run commands using subprocess but it throws error when I change directory

error as UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 972: invali d start byte

  import os
  import subprocess
  while True:
      command = input(">> ")
      cdcommand = command.split(" ")
      if cdcommand[0] == "cd":
         os.chdir(cdcommand[1])
      else:
          result = subprocess.check_output(command , shell = True)
          print (result.decode())
vimuth
  • 5,064
  • 33
  • 79
  • 116

0 Answers0