- 论坛徽章:
- 0
|
我使用pxssh来进行登录,成功登录执行命令发现输出的并不完美,每行后面都有句号,请问怎么处理掉末尾的句号- #!/usr/bin/env python
- import pxssh
- import getpass
- try:
- s = pxssh.pxssh()
- hostname = '127.0.0.1'
- username = 'mjj'
- password = 'mjj2011'
- s.login (hostname, username, password,original_prompt='[$#>]')
- s.sendline ('whoami')
- s.prompt()
- print s.before
- s.sendline ('ping www.baidu.com -c 1')
- s.prompt()
- print s.before
- '''
- s.sendline ('ls -l')
- s.prompt()
- print s.before
- s.logout()
- '''
- except pxssh.ExceptionPxssh, e:
- print "pxssh failed on login."
- print str(e)
复制代码 输出:
whoami
mjj
ping www.baidu.com -c 1
PING www.a.shifen.com (220.181.112.143) 56(84) bytes of data.
64 bytes from 220.181.112.143: icmp_seq=1 ttl=54 time=36.9 ms
--- www.a.shifen.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 36.937/36.937/36.937/0.000 ms |
|