I am doing a script with python to know when someone is connected to my system using ssh in linux mint, I have this:
#! /usr/bin/python3
import subprocess
subprocess.run("who > /home/sergio/Comandos/who.txt",shell=True)
a=subprocess.check_output("cat $HOME/Comandos/who.txt|wc -l",shell=True)
b=a.decode("utf-8").strip()
print(b)
if b>1:
subprocess.run("zenity --info --text 'Alguien se a conectado'", shell=True)
But I get this error:
Traceback (most recent call last):
File "/home/sergio/github/python.file/ssh2.py3", line 14, in <module>
if b>1:
TypeError: '>' not supported between instances of 'str' and 'int'
[Finished in 0.5s with exit code 1]
[cmd: ['/usr/bin/python3', '/home/sergio/github/python.file/ssh2.py3']]
[dir: /home/sergio/github/python.file]
[path: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games]