view postcnv @ 17:76d91e545ea8 default tip

addrsbr and dtimep fix
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 24 Nov 2014 14:49:25 +0900
parents 07f8972434be
children
line wrap: on
line source

#!/usr/bin/perl

my @A = ();
my $i = 0;
my $tmp = "/tmp/postaa$$";
my $host = "yourhost.cr.ie.u-ryukyu.ac.jp";
my $f;
my $file;
my @U;
my $debug = 0;

if ($debug) {
   open(LOG,">>/tmp/postcnv.log");
}

sub mysystem {
   my ($arg) = @_;
   print LOG "$arg\n" if ($debug);
   system $arg;
}

# system "echo @ARGV >> /tmp/ahoaho";

#     /usr/local/mh/lib/post [-alias aliasfile]
#          [-filter filterfile] [-nofilter] [-format] [-noformat]
#          [-mime] [-nomime] [-msgid] [-nomsgid] [-verbose]
#          [-noverbose] [-watch] [-nowatch] [-width columns] file
#          [-help]

while ( @ARGV ) {
    $_ = shift(@ARGV);
    # options require argument
    if( /^-alias/ ) {
       push(@A,$_); $_ = shift(@ARGV); push(@A,$_);
    } elsif( /^-filter/ ) {
       push(@A,$_); $_ = shift(@ARGV); push(@A,$_);
    } elsif( /^-idanno/ ) {
       shift(@ARGV);
       # push(@A,$_); $_ = shift(@ARGV); push(@A,$_);
    } elsif( /^-library/ ) {
       push(@A,$_); $_ = shift(@ARGV); push(@A,$_);
    } elsif( /^-width/ ) {
       push(@A,$_); $_ = shift(@ARGV); push(@A,$_);
    } elsif( /^-/ ) {
       push(@A,$_); 
    } else {
       $f = $tmp . $i++;
       $file = $_;
       push(@A,$f); # push(@U,$_);
    } 
}

# system "refile -link -src +drafts last +send";
# print STDERR "/bin/cp $f $new\n";
if ($file) {
    my $new  = `/usr/local/mh/bin/mhpath +send new`;
    # system("nkf -j -m0 --overwrite $file");   too late?
    mysystem("/bin/cp $file $new");
    mysystem("scp $file ${host}:${f}");
}

# system "echo remote @A >> /tmp/ahoaho";
# how to handle error?
mysystem("ssh  $host /usr/local/mh/lib/post @A");

if (! $debug) {
  mysystem("ssh $host rm $f");
}

# unlink(@U);
1;

#end