I want to be able to search for process name remotely on a machine. I'm using paramiko to run the command "tasklist". The output of the command is in bytes and I cant search for a specific name, so as far as I know I need to use decode() to convert it into string but then I can't loop on all items as well. Any idea how can I do it ?
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(ip, username="Administrator", password="Password1")
print("runnning command")
stdin, stdout, stderr = ssh.exec_command("tasklist")
output = stdout.read()
output = output.decode()
Example for output I get when printing 'output':
Image Name PID Session Name Session# Mem Usage
========================= ======== ================ =========== ============
System Idle Process 0 Services 0 8 K
System 4 Services 0 32 K
Registry 120 Services 0 25,928 K
smss.exe 404 Services 0 500 K
csrss.exe 512 Services 0 2,628 K