procmail
[Top] [All Lists]

SMS and Trimming emails

2004-07-16 20:39:28
I have been working on a script to try to trim emails before
forwarding them to my cellphone

I started off with:

:0c
* ! ^FROM_DAEMON
{
      :0bfw 
       | grep -v "^>" |  perl -e "$/ = undef; $_ = <>; s/\s+/ /sg;
print substr $_, 0, 200"
 
       # Send the copy to the phone and my gmail account for verification
       :0
       ! $SMS, gkreme(_at_)gmail(_dot_)com
}

This did not work:

procmail: Program failure (255) of " egrep -v "^>" | perl -e "$/ =
undef; $_ = <>; s/\s+/ /sg; print substr $_, 0, 200""

or

procmail: Executing " egrep -v "^>" |  perl -e "$/ = undef; $_ = <>;
s/\s+/ /sg; print substr $_, 0, 200""
syntax error at -e line 1, near ";  ="

I then tried

| grep -v "^>" | awk '{ print substr($0 , 0 , 200)}'

But that did not work because the awk only stripped each LINE to 200 characters.

I then tried

| head -c 200 | sendmail -io $SMS

(end eliminated the ! recipe)

but got this
procmail: Executing " head -c 200 | sendmail -io [$SMS]"
sendmail: not found

finally I tried

:0c
* ! ^FROM_DAEMON
{
      # Process only the body, wait for the filter
      :0bfw
       | grep -v "^>" |  head -c 200
 
       # Send the copy to the phone and my gmail account for verification
       :0
       ! $SMS, gkreme(_at_)gmail(_dot_)com
}

Which APPEARS to work (no errors) and works from the command line
(only get 200 bytes) but the copy of the mail I get on my account
contains the entire test message text:

This is the final 200 byte test, sending a message
to the cellphone that exceeds 200 bytes and seeing
if the message is properly cutoff after the fourth
line.  This should be the last line of the message
and this line should not appear at all.

(that is, the 6th line appears in full on the gmail account).  

I'm stuck.

-- 
gkreme at gmail or kreme at kreme or syth at mac

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>