paramiko (python)에 도움이 필요합니다. 나는 비표준 SSH 인터페이스를 가진 서버를 가지고 있기 때문에 대화식 모드를 사용했고 동일한 채널에서 몇 개의 명령을 실행하고있다 (exec_command는 나를 위해 작동하지 않는다). 모든 것은 괜찮지 만 데이터가 수신되지 않을 때 응용 프로그램이 while 루프에 있기 때문에 명령 당 시간 초과를 소개하고자합니다. Channel.settimeout은 첫 번째 명령 이후에 응용 프로그램 시간 초과로 제대로 작동하지 않는 것 같습니다. 스레딩 때문에 신호를 사용할 수 없습니다. 데이터 변수가 비어있는 후 시간을 계산하기 위해 time()을 사용했을 때 전체 코드 실행이 중지되고 채널 데이터를 기다리는 것으로 나타났습니다. 모든 문제를 해결하는 방법에 대한 조언은 높이 평가 될 것입니다.python paramiko 명령에 대한 시간 초과
ssh=paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
connect = ssh.connect(host,username=,password=,timeout=20)
file=open("test.txt","w+")
channel = ssh.invoke_shell()
data = channel.recv(5000)
set_of_commands = ["cmd\n","reset\n"]
while set_of_commands is not None:
file.write(data)
# New command might be executed here if we have 'system:'
if re.match("system:",data) is not None:
try:
command=set_of_commands.pop()
channel.send(command)
except:
break
data=channel.recv(5000)
제한 시간입니다. –
channel.recv_exit_status()를 사용해 보셨습니까? –