🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #324

Re: BASH Script para backup via FTP

#324
From: Gonzalo Pérez de Olaguer Córdoba
Date: Thu, 02 Oct 2008 14:45
56 lines
2150 bytes
Hola Shake <alex.estevezNOSPAM@filnet.es>
el Thu, 02 Oct 2008 14:33:25 +0200 escribiste:

> Algo asi como: para /a/b/c
> 
> que mande los comando ftp
> 
> mkdir /a
> mkdir /a/b
> mkdir /a/b/c
> cd /a/b/c
> put archivo
> cd /
> 
> [...]
> 
> Hay alguna funcion parecida al split() de Perl?

Puedes usar cut:

echo "/a/b/c" | cut -d/ -f2	# returns a
echo "/a/b/c" | cut -d/ -f3	# returns b
echo "/a/b/c" | cut -d/ -f4	# returns c

O directamente en bash:

cd /
DIR="/a/b/c"
while [ -n "$DIR" ] ; do
	FIRST=${DIR#/}
	FIRST=${FIRST%%/*}
	mkdir $FIRST
	cd $FIRST
	DIR=${DIR#/$FIRST}
done

Eso generaría:

cd /
mkdir a
cd a
mkdir b
cd b
mkdir c
cd c

> O si hay algun modo desde el FTP y no pre-tratando los datos...

Ya te han comentado lo de mirrordir.

El programa rsync también te permite usarlo vía FTP, creo, con
la opción --rsh.

-- 
Gonzalo Pérez de Olaguer Córdoba <gpoc@iies.es>
PGP key 2861C704 --- F206 5671 6789 425D 111C  1302 214F 1934 2861 C704
Technical Details
Message-ID: <20081002164546.696d653b@petres.salonet.snet>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!87.106.161.54.MISMATCH!feeder1.news.weretis.net!newsfeeder.dynfx.net!weretis.net!news.antakira.com!mainake.escomposlinux.org!reboot.escomposlinux.org!hercules.escomposlinux.org!escomposlinux.org!not-for-mail
References: <gc2f1n$1mp$1@aioe.org>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!87.106.161.54.MISMATCH!feeder1.news.weretis.net!newsfeeder.dynfx.net!weretis.net!news.antakira.com!mainake.escomposlinux.org!reboot.escomposlinux.org!hercules.escomposlinux.org!escomposlinux.org!not-for-mail
From: Gonzalo Pérez de Olaguer Córdoba <gpoc@iies.es>
Newsgroups: es.comp.os.linux.programacion
Subject: Re: BASH Script para backup via FTP
Date: Thu, 2 Oct 2008 16:45:46 +0200
Organization: escomposlinux.org
Lines: 56
Message-ID: <20081002164546.696d653b@petres.salonet.snet>
References: <gc2f1n$1mp$1@aioe.org>
NNTP-Posting-Host: 84.77.244.205
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-15
Content-Transfer-Encoding: quoted-printable
X-Trace: hercules.cohp1 1222958816 8160 84.77.244.205 (2 Oct 2008 14:46:56 GMT)
X-Complaints-To: newsmaster@news-17.escomposlinux.org
NNTP-Posting-Date: Thu, 2 Oct 2008 14:46:56 +0000 (UTC)
X-Newsreader: Sylpheed-Claws 1.0.5 (GTK+ 1.2.10; i486-pc-linux-gnu)