paramiko
ssh를 사용하여 cat /tmp/file
을 하나의 숫자가 포함 된 원격 컴퓨터에서 실행합니다.b'0에서 int를 전송할 수 없습니다. n '
이 숫자는 0
stdin, stdout, stderr = client.exec_command('cat /tmp/file')
print("stdout:")
print(stdout)
print("\nstdout.read():")
print(stdout.read())
print("\nif not int(errlvl) == 0:")
errlvl = stdout.read()
if not int(errlvl) == 0:
출력과 비교 할 필요가 :
stdout:
<paramiko.ChannelFile from <paramiko.Channel 35 (open) window=2097152 -> <paramiko.Transport at 0x2b36750 (cipher aes128-ctr, 128 bits) (active; 1 open channel(s))>>>
stdout.read():
b'0\n'
int(stdout.read())
Traceback (most recent call last):
[...]
if not int(errlvl) == 0:
ValueError: invalid literal for int() with base 10: b''
가 어떻게이 경우 0
에서 int
값을 사용할 수 있습니다, 내 if
에?
'b'0 \ n' '이 아니며'b ''가 비어 있습니다. 'int (b'0 \ n ')'이 작동합니다. – wim
당신은 옳은 것을 인쇄하지 않습니다. 'print errlvl' –
'stdout.read()'는 파일 포인터를 움직이는데, 다시 호출하면 아무것도 얻지 못합니다. – tamasgal