Jinsy David

Jinsy David

  • NA
  • 46
  • 6.2k

Hey guys, I'm just editing a little code (landscape-sysinfo) that I fo

Mar 4 2021 5:55 AM
Hey guys, I'm just editing a little code (landscape-sysinfo) that I found on the internet. I'm using python 3.9.2. I would like to get the number of users logged into the system (original code uses python-utmp and I cannot use it because I am running the script on my rasp with Arch Linux aarch64). Use the code: import subprocess users = subprocess.Popen ('users', stdout = subprocess.PIPE) userslogged = subprocess.check_output (('wc -w'), stdin = users.stdout) Only userslogged returns "b'2\n'" instead of just "2". Basically I'm running a "users | wc -w" to get the number of instances of users online. How do I get the clean result "2" instead of "b'2\n'"?

Answers (1)