I am trying to copy few files from my local windows directory to remote linux dir.
It is working for file having same kind of extension. But breaks when there are different extensions in a folder.
The Code:
import os
import glob
import paramiko
glob_pattern='*.*'
try:
ssh.connect(host,username=user,password=pwd)
ftp = ssh.open_sftp()
try:
ftp.mkdir(dir_remote)
command=dir_remote+'/setuplog'
ftp.mkdir(command)
commande=dir_remote+'/emsfolder'
ftp.mkdir(commande)
try:
for fname in glob.glob(uploadfolder + os.sep + glob_pattern):
local_file = os.path.join(uploadfolder, fname)
remote_file = dir_remote + '/' + os.path.basename(local_file)
ftp.put(local_file,remote_file)
ftp.chmod(remote_file ,0777)
except IOError, e:
print (e)
except IOError, e:
print (e)
except paramiko.AuthenticationException, ae:
print (ae)
finally:
ssh.close()
I was trying to transfer 2 files only(1.sh and 2.pl). While 1.sh got copied a 0 byte 2.pl file is created at the remote server and then I get The Error:
size mismatch in put! 0 != 2200
I am using:
python 2.7, Paramiko - 1.15.2
Kindly help.