Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Use pysftp to get the content of a remote folder
#1
I managed to get ssh working for me.

Now I want to log in, cd, get all the files in a directory, download them to /home/pedro/essays/ delete the files on the server and logout

The bit I'm not sure of: how to tell sftp where to download the files to??

Will this work?

Quote:remote_file = '*.* /home/pedro/essays/'

Also, what should go in hostname? The ip number or http://www.mywebpage.com?

import pysftp

hostname = '123.456.123.456'
me = 'mycPanelusername'
secret = 'mypassword'
remote_file = '*.* /home/pedro/essays/'

with pysftp.Connection('hostname', username='me', password='secret') as sftp:

    with sftp.cd('/public_html/php/uploads/'):           # temporarily chdir to /public_html/php/uploads/
        #sftp.put('/pycode/filename')  	# upload file to allcode/pycode on remote
        sftp.get('remote_file')         # get remote file(s)
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  How to gather information from remote host using ansible module in python amritjsr 0 29 4 hours ago
Last Post: amritjsr
  Read a remote text file Sandy7771989 1 66 Jul-18-2019, 06:55 PM
Last Post: ndc85430
  Does pysftp need a logout? Pedroski55 2 149 Jun-24-2019, 10:05 PM
Last Post: Pedroski55
  Encoding problems on multiple files in one folder NikolajKorsgaard 5 397 Jun-11-2019, 03:39 AM
Last Post: micseydel
  How to specify the destination folder SriMekala 1 135 May-21-2019, 11:45 AM
Last Post: DeaD_EyE
  Read a folder with a multiple files NewBeie 7 269 May-06-2019, 08:04 AM
Last Post: NewBeie
  folder PyQt5 created during creation exe atlass218 0 128 Apr-26-2019, 06:25 PM
Last Post: atlass218
  How to run python code in Java using remote SSH without py file using streams in Java varanasipavankumar 0 123 Apr-07-2019, 06:13 PM
Last Post: varanasipavankumar
  Smartsheet api data using python into folder dspy9 0 157 Apr-04-2019, 07:30 PM
Last Post: dspy9
  Including classes from folder issue graham23s 1 216 Apr-03-2019, 07:33 AM
Last Post: Gribouillis

Forum Jump:


Users browsing this thread: 1 Guest(s)