Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import paramiko
- import os
- import getpass
- output=''
- host='192.168.0.106'
- user=input('enter username:')
- psw = getpass.getpass()
- try:
- ssh = paramiko.SSHClient()
- ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- ssh.connect(host, username=user, password=psw, port=22)
- except:
- print('login failed')
- exit()
- print(host+' login success')
- try:
- channel = ssh.invoke_shell()
- except:
- print(q+' unknown device type')
- a=input('press enter to exit:')
- exit()
- time.sleep(4)
- channel.send('cd Documents \n')
- time.sleep(1)
- channel.send('cat Hi.txt \n')
- time.sleep(1)
- while channel.recv_ready():
- device_type=''
- #time.sleep(0.5)
- out = channel.recv(99999999)
- device_type=out.decode("ascii")
- output+=device_type
- print(output)
- #if output.endswith('pi@raspberrypi:~/Documents$'):break
- f=open('output.txt','w+')
- f.writelines(output)
- #print (len(output))
Add Comment
Please, Sign In to add comment