...
Python developer wanted to write a script for retrieving a file from a sFTP server. Here's a step-by-step:
- Connect to SFTP repository (Secure FTP)
- Identify files based on filename criteria
- Download these files to local folder
- Run an existing python script
-
source
install.sh
:. ./install.sh
-
set up environment variables FTP_USER and FTP_PWD (or change the default value variable values in the script):
export FTP_USER=... export FTP_PWD=...
-
run
download.py
to download files and run a post processing script:. ./env/bin/activate ./download.py
./download.py -h
usage: download.py [-h] [-u USER] [-p PWD] [--host HOST] [--src SRC]
[--dst DST] [-s SCRIPT] [-P PREFIX]
Downloading and processing files from a SFTP server.
optional arguments:
-h, --help show this help message and exit
-u USER, --user USER SFTP user (default: decmetrics)
-p PWD, --pwd PWD SFTP user password (default: ********)
--host HOST SFTP host (default: 31.3.230.106)
--src SRC SFTP source directory (default: readings)
--dst DST Destination directory (default: readings)
-s SCRIPT, --script SCRIPT
Post processing script (default: ./importfile.py)
-P PREFIX, --prefix PREFIX
Source file name prefix (default: southend_airport)