Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |
Tags
- YOLO
- OpenCV
- VS Code
- Linux
- C++
- Python
- 프로그래머스
- 오류
- Numpy
- ubuntu
- error
- label
- windows forms
- mysql
- paramiko
- SSH
- Docker
- Visual Studio
- pytorch
- C#
- 핑거스타일
- C
- 컨테이너
- nvidia-smi
- Selenium
- 채보
- JSON
- pandas
- 기타 연주
- pip
Archives
- Today
- Total
기계는 거짓말하지 않는다
Python Paramiko module SSH exec_command 블록(wait) 본문
Python의 Paramiko module로 SSH 연결 후 원격 명령어가 끝날 때까지 blocking 하는 방법의 예이다.
import paramiko
import time
cli = paramiko.client.SSHClient()
cli.set_missing_host_key_policy(paramiko.client.AutoAddPolicy())
cli.connect(hostname="1.1.1.1", username="ubuntu")
stdin, stdout, stderr = cli.exec_command("sleep 3")
# waiting for command
stdout.channel.recv_exit_status()
lines = stdout_.readlines()
print(''.join(lines))
cli.close()
stdout.channel.recv_exit_status() 함수를 사용한다.
'Python' 카테고리의 다른 글
| Python pip 패키지 버전 확인 (Package version check) (0) | 2023.08.19 |
|---|---|
| Python subprocess pipe stdin write 중단 문제 (0) | 2023.08.19 |
| Python Pandas 조건에 맞는 데이터 일정 비율 추출 (0) | 2023.05.06 |
| Python SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 8-9: truncated \UXXXXXXXX escape 오류 (0) | 2023.04.29 |
| Python String u'\ufeff' (0) | 2023.04.21 |
Comments