-
LINUX > LFTP
UPLOAD
lftp -e 'put /chemin/fichier.mp4 ; bye' -u user,mdp ftp.foo.com
DURÉE DE LA CONNEXION
LFTP essaiera une connexion perpétuellement. Pour donner une durée maximale d’essais (ex. 10 secondes) :
lftp -e 'set net:timeout 10 ; put /chemin/fichier.mp4 ; bye' -u user,mdp ftp.foo.com
Active Mode
For what it’s worth, Active mode -- older, stinkier, and won’t go through your firewall:
lftp -e 'set ftp:passive-mode false; put /chemin/fichier.mp4; bye' -u user,mdp ftp.foo.com
DOWNLOAD
lftp -e 'get yourfile.mp4 ; bye' -u user,mdp ftp.foo.com
Pour spécifier un dossier local spécifique :
lftp -e 'get yourfile.mp4 -o /chemin/fichier.mp4 ; bye' -u user,mdp ftp.foo.com
MIRRORING
Recursive Upload
When using the
mirror
command, LFTP is recursive by default.Mirror everything from the
/local/path
to the root of the remote FTP site, including all subdirectories and their files. The -R switch means "reverse mirror" which means "put" [upload]. Remote path is simply/
, the root :lftp -e 'mirror -R /local/path/ /' -u user,password ftp.foo.com
Recursive Download
To mirror remote to local, just omit the
-R
param and swap remote path with local. Be careful with this. Don’t overwrite your local changes :lftp -e 'mirror / /local/path/' -u user,password ftp.foo.com
RegEx
Ne prendre que les fichiers
.htm
,.html
,.css
, et.js
:lftp -e 'mirror -R -i "\.(html?|css|js)$" /local/path/ /' -u user,mdp ftp.foo.com
Non-Recursive
The
-r
switch disables recursion. In this example, we are also only deploying HTML, CSS, and JavaScript :lftp -e 'mirror -R -r -i "\.(html?|css|js)$" /local/path/ /' -u user,mdp ftp.foo.com
CARACTÈRES SPÉCIAUX DANS LE USERNAME OU PASSWORD
Les caractères spéciaux peuvent être échappés :
lftp -e 'put /chemin/vers/fichier.mp4; bye' -u user,mdp\!\! ftp.foo.com
ou bien encadrés par des guillemets :
lftp -e 'put /chemin/vers/fichier.mp4; bye' -u "user,mdp!!" ftp.foo.com