Transfer file to linux server with Python

0

Hello,

I want to make a Python file that will transfer all files from a local folder of my Windows to a specific path on my CentOS 7 server >. At first this server is on my local network , but it would be interesting to make a transfer to an external server in the future.

Any tips on how I can do this procedure with python will be of great help!

Any doubts, I am at your disposal.

    
asked by anonymous 12.09.2017 / 21:12

1 answer

1

If CentOS has access via SSH / SFTP you can install the link module and run a python script like this:

import pysftp

with pysftp.Connection('NOME DO HOST', username='USUARIO', password='SENHA') as sftp:
    with sftp.cd('public'):             # navega para uma pasta especifica
        sftp.put('c:/foo/bar/baz.txt')  # faz o upload para a pasta public
  

Note: The installation does not seem to be available via pip , you can download .tar.gz

    
12.09.2017 / 21:51