less than 1 minute read

import paramiko

import os


 

host = 'APKRP-WFSR193'

port = 22

user = 'gukim00'

password = 'chubb@ce12!'


 

transport = paramiko.Transport((host,22))

transport.connect(username=user, password = password)

sftp = paramiko.SFTPClient.from_transport(transport)


 

def getftp(remote_path,local_path):

  # sftp = paramiko.SFTPClient.from_transport(transport)

  sftp.chdir('/')

  sftp.get(remote_path,local_path)

  # sftp.close()

  # transport.close()


 

def toftp(local_path,remote_path):

  # sftp = paramiko.SFTPClient.from_transport(transport)

  sftp.chdir('/')

  sftp.remove(remote_path)

  sftp.put(local_path,remote_path)

  # sftp.close()

  # transport.close()

def file_list(remote_path):

  sftp.chdir('/')

  return sftp.listdir(remote_path)

 

# getftp('AI_LNC_Summary_20230216.xlsx', r'C:\Users\gukim00\Desktop\DB추출\AI_LNC_Summary_20230216.xlsx')

# toftp( r'C:\Users\gukim00\Desktop\DB추출\PP2_2.xlsx','/path/PP2_2.xlsx')

Leave a comment