python paramiko invoke_shell_Python,paramiko,invoke_shell和丑陋的字符
當我運行以下
Python代碼時:
import workflow
import console
import paramiko
import time
strComputer = 'server.com'
strUser = 'user'
strPwd = 'passwd'
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(hostname=strComputer, username=strUser, password=strPwd)
channel = client.invoke_shell()
channel.send('ls\n')
time.sleep(3)
output=channel.recv(2024)
print(output)
#Close the connection
client.close()
print('Connection closed.')
我得到了與丑陋字符混合的所需輸出:
Last login: Thu Jun 19 23:37:55 2014 from 192.168.0.10
ls
user@server:~$ls
[0m[01;34mbin[0m Rplots1.pdf
[01;32mbtsync[0m Rplots.pdf
btsync.conf~ [01;31mrstudio-server-0.95.265-amd64.deb[0m
[01;31mbtsync_glibc23_x64.tar[0m screen.vba
[01;34mbudget[0m [01;34mshiny[0m
[01;3
Connection closed.
任何人都可以解釋我發生了什么,以及如何獲得一個漂亮的輸出?
謝謝
最佳答案 這些是ls使用的終端顏色代碼,用于突出顯示目錄,可執行文件等.您可以顯式調用/ bin / ls(或者,在某些發行版上,ls –color = never)以避免調用別名等并獲得無色輸出.
顏色是使用像[0m [01; 34m.
這是啟用ls著色時終端的樣子:
總結
以上是生活随笔為你收集整理的python paramiko invoke_shell_Python,paramiko,invoke_shell和丑陋的字符的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 练习图200例图纸讲解_【宅家数学课23
- 下一篇: d3.js 旋转图形_苏教版三年级数学上