Re: SMS Forwarding
LuKreme <[email protected]>
| Newsgroups | gmane.mail.procmail |
|---|---|
| Message-ID | <[email protected]> |
On 23 Jan 2014, at 02:35 , [email protected] wrote: > in message <[email protected]>, > wrote LuKreme thusly... >> >> >> On 21 Jan 2014, at 23:43 , LuKreme <[email protected]> wrote: >> >>> | formail -I"" \ >>> | grep -v "^>" \ >>> | perl -e "$/ = undef; $_ = <>; s/\s+/ /sg; print substr $_, 0, 200" > > In case of significant, important work being done on mail, it would > be best to save that in a file so that the script|program can be > easily tested. > > When invoking perl, simply do the quote avoidance there too … Thanks! I’ll give this a whirl. > > #!/path/of/perl > > use strict; use warnings; > > # This programs is based on above quoted one. This does not send > # any mail on its own. It is expected to be given only the > # body of an email message. > # > # It prints a string of size of less than or equal to $max_char. > > my $max_char = 200; > my $quote_re = qr{^ \s* >}x; > my $sign_re = qr{^ ---? \s* $}x; > > my @body; > while ( my $line = <STDIN> ) > { > $line =~ $sign_re and last; > > # Simplistic quote avoidance may not work reliably with > # "format=flowed" Content-type. > $line =~ $quote_re and next; > > push @body , $line; > } > scalar @body or exit; > for ( @body ) > { > s/^\s+//; > s/\s+$//; > s/\s+/ /g; > } > my $body = join ' ' , @body; > > print > length $body <= $max_char > ? $body > : substr $body , 0 , $max_char > ; > > __END__ > > >> Oh, that generates an error: >> >> procmail: Program failure (255) of " formail -I"" | grep -v "^>" | >> /usr/bin/perl -e "$/ = undef; $_ = <>; s/\s+/ /sg; print substr >> $_, 0, 200"" > > Does the above runs on Unix or Unix-like system? If so, change > double quotes around perl one-liner to single quotes. And that as well. > (You should be aware that above various caveats apply when using > simplistic mail munging.) Sure, but for the purposes of SMS alerts as long as I make sure it’s processing a COPY of the message it hardly matters. Worst case, I don’t get the alert. -- he'd moved like music, like someone dancing to a rhythm inside his head. And his face for a moment in the moonlight was the skull of an angel...