Télécharger une liste de fichiers en FTP

Mars 2013

Aucun des principaux clients FTP (Filezilla, WinSCP, cuteftp...) ne permet de télécharger une liste de fichiers en FTP, en conservant la structure des dossiers sur le serveur.

Ici nous allons voir comment télécharger une liste de fichiers FTP assez facilement, en ligne de commande.

WinSCP est un client FTP avec une interface graphique, comme Filezilla. Mais il offre l'énorme avantage de proposer également une interface en ligne de commande, et c'est qu'on va utiliser.

Commencez par télécharger WinSCP sur le site officiel, prenez par exemple la version Portable executables (qui ne nécessite aucune installation, il suffit d'extraire le zip).

Ensuite, lancez le programme et configurez une première connexion, que vous nommerez par exemple MaConnexionFTP (il faut cliquer sur Save pour pouvoir enregistrer la connexion).

WinSCP connexion

Une fois que votre connexion fonctionne, fermez WinSCP (il va stocker les informations de connexion dans le fichier WinSCP.ini).

Maintenant on va pouvoir écrire un script WinSCP, qui est en fait la liste des fichiers à télécharger :

open MaConnexionFTP
option transfer binary

get ./wp-config.php                             backup_ftp\wp-config.php
get ./wp-includes/version.php                   backup_ftp\wp-includes\version.php
get ./wp-includes/js/codepress/codepress.js     backup_ftp\wp-includes\js\codepress\codepress.js

Enregistrez ça dans un fichier que vous nommerez : list-download-script.txt.

Maintenant il ne reste plus qu'à télécharger cette liste avec WinSCP. Pour ça, lancez une invite de commande (cmd.exe) dans le dossier où vous avez enregistré la liste ci-dessus, et utilisez cette commande :

winscp.exe /script=list-download-script.txt

On peut aussi optionnellement demander un log FTP :

winscp.exe /script=list-download-script.txt /log=list-download.log

Les fichiers seront alors téléchargés avec les paramètres de MaConnexionFTP, dans le dossier Local directory que vous avez défini dans les paramètres de la connexion. WinSCP va recréer l'arborescence (les dossiers et sous-dossiers) en local pour avoir une structure identique au serveur.

Dans un tout autre contexte, cet article est très intéressant : changer l'ordre des colonnes excel.

Backup FTP automatique

Étant donné que tout ça fonctionne en ligne de commande, on peut parfaitement s'en servir pour faire des backups automatiques de serveur FTP (avec des tâches planifiées).

Pour cela, au lieu d'appeler winscp en ligne de commande, il suffit de placer la commande dans un fichier .bat.

Creéz donc un nouveau fichier .bat que vous nommerez comme le fichier qui contient la liste, mais avec l'extension .bat : list-download-script.bat.

Dedans, écrivez ceci :

winscp.com /script="%~n0.txt"
pause

Ce script est "intelligent", il détermine le nom du fichier liste à télécharger à partir de son propre nom de fichier, du coup on peut facilement le réutiliser dans le modifier, pour gérer différentes listes.

Le pause sert juste à ne pas fermer l'invite de commande une fois le téléchargement terminé.

Encore faim ? allez lire ça : canette de soda !

1 commentaire :
commentaire n°4173 par jameser239@gmail.com
jameser239@gmail.com jeudi 27 juin 2019, 14:05
Learn If A Home Based Business Enterprise Fits Your Needs

A home business can simply result in failure. The advice shared here will assist you to learn how to give your company the attention it must have in order to thrive.

Get receipts from lunches with prospects and colleagues, since you can deduct expenses such as these at tax time. These are legitimate business expenses and must be treated as a result. Remember, these meetings must have to do with work and they are with viable clients or potential clients, otherwise, they cannot be allowed as a tax deduction.

Turn it into a top priority in your web business to maintain your current patrons happy and meet their needs. As opposed to selling to a different customer, it is much easier to sell to people who have purchased from you before and were satisfied. A cheerful customer will return over and over again.

Do not quit the day job when you begin your work at home business. A brand new business might take time before it could generate profit, therefore, it is advisable to keep your job going. You will find benefits of this, including possessing a steady income while you watch for your company to make revenue.

To spend less, record your business expenses. It is advisable to monitor expenses, such as office supplies and Internet service. You can receive tax deductions for a number of these expenses. Even trivial expenses can mount rapidly, and it's foolish to easily permit the government keep even a small fraction of your profits.

Through online message boards, you will discover support from different do business from home companies for improving your online business. You can get an extensive number of online forums and websites committed to various home-business topics, and also the support, information and advice it is possible to profit from these resources are priceless. You will find other home-based business owners that can give you advice.

To totally tap into the your web business potential, you need to use the Internet to showcase it. Ensure that the strategies you employ work well. Blogs, article writing, forums, and emails are typical great ways to get your business more visibility totally free, leading to more visitors.

You can find a number of people who run their own personal home businesses online. Browse around the Internet for forums or discussion boards where people your small business swap strategies. Finding these conversations can present you with some good ideas for improving your own home business enterprise.

Set a schedule to function. You will probably find yourself working long hours and disrupting all of your life if you don't decide on a set work routine. You have to have scheduled free time exactly like you would if you had a job with an outside company. You'll keep your social interaction intact in this manner.

Will not think you will get rich overnight, be realistic. Is your product high quality, and may customers continue to be considering it? Are you presently an upstanding individual who values honesty?

While having a home based business can take lots of effort and time, you'll gladly recognize that all businesses starts off this way. Whether it was, the whole world will be rich, it is far from easy to become loaded with one day. You will know that everything you've worked towards will work out for you in the end, by ensuring that you strive and also have a firm foundation.


https://twitter.com/GeffenOody


oody geffen
facultatif
Facebook Twitter RSS Email
Forum Excel
Venez découvrir le nouveau forum excel question/réponse à la stackoverflow.com !
Forum Excel
hit parade n'en a rien a foutre du W3C Positionnement et Statistiques Gratuites Vincent Paré