Apagada docs

Aprendiendo a programar el pasado

Herramientas de usuario

Herramientas del sitio

Recursive ftp get using sed

This sed script takes a ftp file list generated by 'mdir -R' and outputs a ftp script to recursively get contents of ftp.

I use this in a hosting provider that does not provide means of making backups or zipping directory trees.

PLEASE NOTE '%CD:\=\/%' makes reference to a MS-WINDOWS environment string. So this file has to be generated from a batch file (i.e. with ECHO XXX»file.sed) in order to put the value of the environment string inside the script.

#Line not ending in ":\n" => get filename at char 63.
  s/^.\{62\}/get /;
  #delete "get ." and "get .."
  /get \.\{1,2\}.$/d;
#Line ending in ":\n" => this is a directory name.
  #Hold a copy
  #Insert "cd " at start. Delete spurious "." (or replace with home directory name).
  s/^/cd /;
  s/cd \./cd /g;
  #Print line and work on second copy
  #Insert "!mkdir" and current dir at start. (Replace \ with \\). Reverse slashes.
  s/^/!mkdir %CD:\=\\%\\/g;
  #Hold another copy.
  #Print and return to copy
  #Replace !mkdir with lcd.
  s/^!mkdir /lcd /;
#Delete empty lines (I use this since I cannot search for "^\n$").

Example of usage (for ms-dos users with sed installed):

type mdir_file |sed -e "/:.$/!{;s/^.\{62\}/get /;/get \.\{1,2\}.$/d;};/:.$/{;s/:.$//;h;s/^/cd /;s/cd \./cd /g;p;g;s/^/!mkdir %CD:\=\\%\\/g;s!/!\\!g;s/\\[.]\\/\\/g;h;p;g;s/^!mkdir /lcd /;};/^[^0-9A-Za-z]$/d" >>text_file_to_paste_inside_ftp_client
Este sitio web utiliza cookies. Al utilizar el sitio web, usted acepta almacenar cookies en su computadora. También reconoce que ha leído y entendido nuestra Política de privacidad. Si no está de acuerdo abandone el sitio web.Más información
start/en/sed/recursive_ftp_get.txt · Última modificación: 2013/10/19 17:44 por nepenthes