f4ukp | J'ai trouvé !!
http://www.tux.org/~peterw/
Dans la section OS/2 stuff
Code :
- #!/usr/bin/perl
- # Perl script to convert PM Mail (v 1.91) for OS/2 email folders
- # to Netscape (v 4) Messenger for Linux
- # Also required is the "file-lib.pl" script, which I'm just using
- # to make a Perl-clean "ls $DIR/*.fld" call
- #
- # Usage: simple, mount your OS/2 drive, set $top_dir to the name
- # of the PM Mail account folder, and then set $new_dir to a temp
- # dir name. Run the script. That's it.
- #
- # It will try to keep your existing folder names, but converts
- # " " to "_", and "/" to "-", and then tosses any other characters
- # besides letters or numbers, just to be safe.
- #
- # Seriously, I renamed my (empty) ~/nsmail in case Netscape
- # got mad, and did a "cp -r /tmp/nsmail ~/nsmail" without Netscape
- # running... As soon as you try to open a folder Netscape will do
- # some initial parsing, and thanks to BoB and Icon, PMMail even
- # marks the "read" messages correctly !!!
- #
- # This script is copyright 1997 Peter W, copying allowed under
- # terms of the GNU Copyright (http://www.gnu.org/)
- #
- # Please email me if you have any troubles or suggestions, though
- # I'd bet we're all just going to use this once ;-)
- #
- # -Peter W (mailto:peterw@clark.net)
- # July 18, 1997
- #
- # Note to BoB & Icon: thanks for the great mail app. Nothing else comes
- # close to PM Mail. Now if you'd only make a Linux version I'd be very
- # happy. Best of luck to you both.
- #
-
- require "file-lib.pl";
-
- $top_dir = "/os2/ftpware/southsde/pmmail/peterw_1.act";
- $new_dir = "/tmp/nsmail";
-
- $tally = 0;
- $start[$tally] = $top_dir;
- $target[$tally] = $new_dir;
-
- $tally += 1;
-
- for ($out_loop = 0 ; $out_loop < $tally ; ++$out_loop ) {
- &MakeFolder($start[$out_loop],$target[$out_loop]);
- }
-
- exit 0;
-
- # -------------------------------------------------------------
- sub MakeFolder {
- local ($start_dir,$final_dir) = @_;
-
- if ( ($start_dir eq "" ) || ($final_dir eq "" ) ) { return 0; }
-
- local @Subdirs, $make_subdir, $num_Subdirs, $loop;
- local @Startdirs, $buffer, $filename;
- local $wkday, $from_line, $wkday, $month, $monum, $time, $year;
- local $write_folder;
-
- #print "Starting with \"$start_dir\", writing to \"$final_dir\"\n";
-
- $write_folder = 1;
-
- if (! open(INI,"<$start_dir/folder.ini" ) ) {
- print "Cannot open folder.ini\n";
- $write_folder = 0;
- #exit 3;
- }
-
- $_ = <INI>;
- close INI;
- $pm_name = "";
- ($pm_name,$other) = split /\xde/, $_;
- while ( $pm_name =~ / / ) { $pm_name =~ s/ /\_/; }
- while ( $pm_name =~ /\// ) { $pm_name =~ s/\//\-/; }
- while ( $pm_name =~ /[^\w\_\-]/ ) { $pm_name =~ s/[^\w\_\-]//; }
- if ( $pm_name ne "" ) {
- #print "Looks like we should call this folder \"$pm_name\"\n";
- }
-
- if (! open(BAG,"<$start_dir/folder.bag" ) ) {
- print "Cannot open folder.bag\n";
- $write_folder = 0;
- #exit 1;
- }
-
- #print "Trying to chdir to $start_dir\n";
- if (! chdir($start_dir) ) {
- print "Can't get to directory\n";
- exit 5;
- }
-
- #print "Getting list of directories in $start_dir\n";
- @Subdirs = &ListFiles($start_dir,'\.fld$');
- $make_subdir = 0;
- $num_Subdirs = @Subdirs;
- for ($loop = 0; $loop < $num_Subdirs; ++$loop) {
- $sub1 = $Subdirs[$loop];
- #print "Checking out $sub1\n";
- if ( $sub1 =~ /\w/ ) {
- $make_subdir = 1;
- if ( $pm_name ne "" ) {
- $start[$tally] = $Startdirs[$loop] = $start_dir."/".$Subdirs[$loop];
- $target[$tally] = $final_dir."/".$pm_name.".sbd";
-
- }
- else {
- $start[$tally] = $Startdirs[$loop] = $start_dir."/".$Subdirs[$loop];
- $target[$tally] = $final_dir;
- }
-
- $tally += 1;
- #print "call ".$start[$tally]." ".$target[$tally]."\n";
- #print "call ".$Startdirs[$loop]."\n";
- # ".$Subdirs[$loop]."\n";
-
- }
- }
- if ( ($make_subdir == 1) && ( $pm_name ne "" ) ) {
- mkdir( $final_dir."/".$pm_name.".sbd", 0700);
- #print "Making dir \"". $final_dir."/".$pm_name.".sbd\"\n";
- }
-
- if ($write_folder == 1 ) {
-
- if (! open(MBOX,">$final_dir/$pm_name" ) ) {
- print "Cannot open temp mailbox\n";
- exit 2;
- }
-
- while(<BAG> ) {
- while (/\n/) { s/\n//; }
- while (/\r/) { s/\r//; }
- ($x,$y,$date,$time,$subject,$to_at,$to_name,$from_at,$from_name,$size,$filename) = split /\xde/, $_;
- $filename = uc($filename);
- if ( open(MSG,"<$filename" ) ) {
- $buffer = "";
- while(<MSG> ) {
- $buffer .= $_;
- if ( /^Date\: / ) {
- # parse the date for mbox
- ($pre,$wkday,$monum,$month,$year,$time,$offset) = split / /, $_;
- $wkday =~ s/\,//;
- $from_line = "From - $wkday $month $monum $time $year\n";
- }
- }
- print MBOX $from_line;
- print MBOX $buffer;
- close MSG;
- }
- else {
- print "Cannot open \"$filename\"\n";
- }
- } # looping through folder.bag
- close BAG;
- } # if Write_folder == 1
-
- return 0;
-
- }
- # -------------------------------------------------------------
|
et le deuxieme fichier
Code :
- #!/usr/bin/perl
- # file-lib.pl , basic file functions
- #usage array ListFiles($dir,$regexp) returns array of files in $dir whose patterns match $regexp
- #usage int LogAppend($filename,$message) appends $message to $filename or returns non-zero
- return 1;
- exit 0;
- # -----------------------------------------------------------------------------------------
- sub ListFiles { # directory, regexp returns @list
- #usage array ListFiles($dir,$regexp) returns array of files in $dir whose patterns match $regexp
- local ($dir,$regexp) = @_;
- local $this_line,@list,@allfilesx,$listpos,$num_filesx,$file_namex;
- $this_line ="";
- $listpos = 0;
- @list = ("" );
- @allfilesx = ("" );
- $listpos =0;
- $num_filesx = 0;
- $file_namex = "";
- if ( opendir (LISTFILESSTORAGE_DIR, $dir) ) {
- # Looks alright
- @allfilesx = grep !/^\./, readdir LISTFILESSTORAGE_DIR;
- $num_filesx = @allfilesx;
- if ( $num_filesx == 0) {
- # No files yet. Goodbye
- } #how many files
- else {
- foreach $file_namex ( @allfilesx ) {
- #print "ListFiles considering \"$file_namex\"\n";
- if ( $file_namex =~ /$regexp/ ) {
- #print "Looks fine\n";
- $list[$listpos] = $file_namex;
- $listpos += 1;
- }
- }
- }
- }
- return @list;
- }
- # -----------------------------------------------------------------------------------------
- # -----------------------------------------------------------------------------------------
- sub LogAppend {
- #usage int LogAppend($filename,$message) appends $message to $filename or returns non-zero
- local($filename,$message) = @_;
- local $this_line,$floop;
- for ( $floop = 0 ; $floop < 3 ; ++$floop ) {
- sleep ($floop);
- if ( open(LOGFILE,">>$filename" ) ) {
- print LOGFILE $message;
- $floop = 10;
- close LOGFILE;
- return 0;
- }
- }
- if ( $floop < 10 ) { return -1; }
- return 0;
- }
- # -----------------------------------------------------------------------------------------
|
Message édité par f4ukp le 23-01-2004 à 00:49:50 ---------------
Radio Club de Fontainebleau F8KTH
|