Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Use pysftp to get the content of a remote folder
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

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'/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)

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Does pysftp need a logout? Pedroski55 2 254 Jun-24-2019, 10:05 PM
Last Post: Pedroski55
  Delete directories in folder is not working after folder is updated asheru93 2 278 Feb-13-2019, 12:37 PM
Last Post: asheru93
  pysftp pop-up 'Client forking' micksulley 5 602 Dec-21-2018, 02:07 AM
Last Post: Larz60+
  copy content of folder to existing folder shlomi27 0 497 Aug-11-2018, 01:44 PM
Last Post: shlomi27
  PySFTP ChDir Error490 whoknows 2 1,296 Jan-19-2018, 08:18 PM
Last Post: whoknows
  PYSFTP - Password Change torz 0 758 Dec-11-2017, 02:32 AM
Last Post: torz

Forum Jump:

Users browsing this thread: 1 Guest(s)