Inici de sessió d'usuariNavegacióCercaDarrers articles
|
Com passar de "mailbox" a "maildir"He de dir que portava temps intentant migrar de mailbox a maildir, ja que m'havia fet amb diversos scripts per fer-ho, i cap havia funcionat correctament.
#!/usr/bin/perl
#
# mbox2maildir: coverts mbox file to maildir directory - the reverse of
# maildir2mbox from the qmail distribution.
#
# Usage: mbox2maildir uses the same environment variables as maildir2mbox:
# MAILDIR is the name of your maildir directory; MAIL is the name of your
# mbox file; MAILTMP is ignored. MAIL is deleted after the conversion.
#
# WARNING: there is no locking; don't run more than one of these! you
# have been warned.
#
# based on convert-and-create by Russell Nelson <nelson(arrova)qmail.org>
# kludged into this by Ivan Kohler <ivan(arrova)voicenet.com> 97-sep-17
# modified by Christian Peraferrer <corellian(arrova)users.sourceforge.net> 05-jan-7
require 'stat.pl';
local $SIG{HUP} = 'IGNORE';
local $SIG{INT} = 'IGNORE';
local $SIG{QUIT} = 'IGNORE';
local $SIG{TERM} = 'IGNORE';
local $SIG{TSTP} = 'IGNORE';
($name, $passwd, $uid, $gid, $quota, $comment, $gcos, $dir, $shell) =
getpwuid($<);
die "fatal: home dir $dir doesn't exist\n" unless -e $dir;
&Stat($dir);
die "fatal: $name is $uid, but $dir is owned by $st_uid\n" if $uid != $st_uid;
chdir($dir) or die "fatal: unable to chdir to $dir\n";
$spoolname = "$ENV{MAILDIR}";
-d $spoolname or mkdir $spoolname,0700
or die("fatal: $spoolname doesn't exist and can't be created.\n");
chdir($spoolname) or die("fatal: unable to chdir to $spoolname.\n");
-d "tmp" or mkdir("tmp",0700) or die("fatal: unable to make tmp/ subdir\n");
-d "new" or mkdir("new",0700) or die("fatal: unable to make new/ subdir\n");
-d "cur" or mkdir("cur",0700) or die("fatal: unable to make cur/ subdir\n");
open(SPOOL, "<$ENV{MAIL}")
or die "Unable to open $ENV{$MAIL}\n";
$i = time;
while(<SPOOL>) {
if (/^From/) {
$fn = sprintf("new/%d.$$.mbox", $i);
open(OUT, ">$fn") or die("fatal: unable to create new message");
$i++;
next;
}
s/^>From/From/;
print OUT or die("fatal: unable to write to new message");
}
close(SPOOL);
close(OUT);
unlink("$ENV{MAIL}");Per fer-ho més senzill us podeu baixar l'script: $ chmod +x mbox2maildir Un cop fet això, per executar l'script s'han de definir unes variables d'entorn, $ export MAIL=/var/spool/mail/$USER $ export MAILDIR=$HOME/.maildir/ i seguidament ja estarem preparats per executar l'script: $ ./mbox2maildir Si tot ha anat bé, i no ha donat cap error, ja hauriem de tenir el correu que teniem en format mailbox al nostre Qualsevol dubte o suggerencia, ho podeu deixar com a comentari. Ja que personalment vaig tenir un altre problema a l'hora de convertir-ho però que se surt de l'objectiu d'aquest article.
|
Llista de correu
Fer-la petar i coordinar-se pel programari lliure. Consultes, propostes, noticies, compartir coneixement, critica, etc.
Més eines webEnquestaUtilitzes programari lliure a la feina o al centre docent?
Completament amb GNU/Linux
29%
Només alguns programes lliures (OOo, Firefox,...)
29%
Tot privatiu, política de l'empresa
43%
Tot privatiu, no saben o no ho tenen clar
0%
Tot privatiu i il·legal
0%
Total votes: 7
Gràcies a : |
y al revés...
A mi me ocurrió hace no mucho que necesitaba el paso contrario, convertir una serie de directorios maildir a formato mbox, en concreto era para poder recuperar un monton de mails que tenía en una m@¡quina vieja en la que estaba usando Kmail, y que quería organizar con hypermail (muy útil), el cual solo admite ficheros mbox...
El script en cuestión lo encontré aquí