Python - Error en if con salida de comando (Python 3)

 
Vista:
sin imagen de perfil
Val: 16
Ha disminuido su posición en 8 puestos en Python (en relación al último mes)
Gráfica de Python

Error en if con salida de comando (Python 3)

Publicado por Sergio (11 intervenciones) el 22/08/2018 17:14:55
Estoy haciendo un script con python para saber cuando alguien se a conecatdo a mi sistema mediante ssh en linux mint, tengo esto:


1
2
3
4
5
6
7
8
9
10
#! /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)


Pero me sale este error:

Traceback (most recent call last): File "/home/sergio/github/python.file/ssh2.py3", line 14, in 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]
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 16
Ha disminuido su posición en 8 puestos en Python (en relación al último mes)
Gráfica de Python

Error en if con salida de comando (Python 3)

Publicado por Sergio (11 intervenciones) el 22/08/2018 17:46:45
El fallo está resuelto, solo había que poner un int, pero cuando lo intentaba solucionar introducía un init, fallo tonto.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar