Jul-09-2021, 08:37 AM
hey all,
i know this might be a dull question, but i dont get it...
this works in python2
wbr
chris
i know this might be a dull question, but i dont get it...
this works in python2
#!/usr/bin/env python import subprocess proclist = subprocess.check_output(['ps', 'uaxw']).splitlines() cfeagent_procs = [proc for proc in proclist if 'cf-agent' in proc] cfeagent_count = len(cfeagent_procs) print(cfeagent_count) if cfeagent_count > 10: print("agents high")
Output:root@aixhemadbprc2: /root # ./process_count.py
145
agents high
but not in python3Error:root@aixhemadbprc2: /root # ./process_count.py
Traceback (most recent call last):
File "./process_count.py", line 6, in <module>
cfeagent_procs = [proc for proc in proclist if 'cf-agent' in proc]
File "./process_count.py", line 6, in <listcomp>
cfeagent_procs = [proc for proc in proclist if 'cf-agent' in proc]
TypeError: a bytes-like object is required, not 'str'
sorry i need a hint...wbr
chris