checking file size in a remote server using python, SSH -


someone please help!

im writting python script retrieve file size in local pc , remote server. then, is, compare if file's size same. below code :

a = "/path/of/the/file/in/my/local/pc" b = "/path/of/the/file/in/remote/pc"  statinfo1 = os.stat(a) statinfo2 = os.system ("ssh" " root@192.168.10.1" " stat -c%s "+b)  if statinfo1 == statinfo2 :    print 'awesome' else :    break 

problem encountered : statinfo1 able return file size in local pc, statinfo2 not able return file size.. please help? want use ssh method

why dont use paramiko sshclient. nifty third party library simplifying ssh access.

so check file size of remote file code -

import paramiko, base64  b = "/path/of/the/file/in/remote/pc"  key    = paramiko.rsakey(data=base64.decodestring('aaa...')) client = paramiko.sshclient() client.get_host_keys().add('ssh.example.com', 'ssh-rsa', key) client.connect('192.168.10.1', username='root', password='yourpassword') stdin, stdout, stderr = client.exec_command("stat -c " + b) line in stdout:     print '... ' + line.strip('\n') client.close() 

check - how size of remote file? , ssh programming paramiko


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -