Getting at incoming message contents?

View: New views
6 Messages — Rating Filter:   Alert me  

Getting at incoming message contents?

by Pierre Fortin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Using:  execute "myscript %F"

Can someone give me a clue as to how to access an incoming message's body
when %F passes "/home/pierre/.claws-mail/tempfolder/processing/253" which
is no longer available when my script gets invoked?  There is no other
pointer to the actual message (now in inbox) that I can find, and no %b
(Body) available on "execute"...

I'm trying to have CM send partial contents of certain messages to my
cell phone via SMS for immediate attention while I'm away from my
computer... I've been doing this with subject lines; but now I have a need
to get at an incoming message's body to create an SMS message which is
limited to 160 chars.  :(

I'd be happy with a hidden option that delayed the deletion of the message
from the processing folder if body access is not currently available.  :)

Then again, I may be overlooking something obvious due to my height  :D

Thanks,
Pierre



---------------------------------------------------------------------
To unsubscribe, e-mail: claws-mail-users-unsubscribe@...
For additional commands, e-mail: claws-mail-users-help@...


Re: Getting at incoming message contents?

by Colin Leroy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 08 October 2008 at 12h10, Pierre Fortin wrote:

Hi,

> Using:  execute "myscript %F"
>
> Can someone give me a clue as to how to access an incoming message's
> body when %F passes
> "/home/pierre/.claws-mail/tempfolder/processing/253" which is no
> longer available when my script gets invoked?  There is no other
> pointer to the actual message (now in inbox) that I can find, and no
> %b (Body) available on "execute"..

%F should work, is your script asynchrone?

--
Colin


signature.asc (196 bytes) Download Attachment

Re: Getting at incoming message contents?

by Pierre Fortin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, 8 Oct 2008 20:10:21 +0200 Colin Leroy wrote:

>On 08 October 2008 at 12h10, Pierre Fortin wrote:
>
>Hi,
>
>> Using:  execute "myscript %F"
>>
>> Can someone give me a clue as to how to access an incoming message's
>> body when %F passes
>> "/home/pierre/.claws-mail/tempfolder/processing/253" which is no
>> longer available when my script gets invoked?  There is no other
>> pointer to the actual message (now in inbox) that I can find, and no
>> %b (Body) available on "execute"..
>
>%F should work, is your script asynchrone?

How to make it so?  My test is very basic:

execute "myscript %F"

myscript:
#!/bin/bash
cat >> myscript.log <<EOF
$*
EOF
cat $1 > myscript.msg

myscript.log:
/home/pierre/\.claws\-mail/tempfolder/processing/253

myscript.msg:
[empty]

Thanks,
Pierre



---------------------------------------------------------------------
To unsubscribe, e-mail: claws-mail-users-unsubscribe@...
For additional commands, e-mail: claws-mail-users-help@...


Re: Getting at incoming message contents?

by Colin Leroy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 08 October 2008 at 14h10, Pierre Fortin wrote:

Hi,

> How to make it so?  My test is very basic:
>
> execute "myscript %F"
>
> myscript:
> #!/bin/bash
> cat >> myscript.log <<EOF
> $*
> EOF
> cat $1 > myscript.msg
>
> myscript.log:
> /home/pierre/\.claws\-mail/tempfolder/processing/253
>
It works for me... Using:
#!/bin/bash
echo $1
cat $1
cp $1 /tmp/prout

When running Claws from the console I get
/home/colin/.claws-mail/tempfolder/processing/1
[contents of the mail]

and /tmp/prout contains the mail as well...

It's strange that in myscript.log you get escaped . and -
(\.claws\-mail), maybe that's to investigate... It isn't Claws that
makes this escaping.
--
Colin


signature.asc (196 bytes) Download Attachment

Re: Getting at incoming message contents?

by Pierre Fortin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, 8 Oct 2008 20:33:54 +0200 Colin Leroy wrote:

>It's strange that in myscript.log you get escaped . and -
>(\.claws\-mail), maybe that's to investigate... It isn't Claws that
>makes this escaping.


Using python instead, it still escapes the filename and can't read the
file:

cmtest.py (I used "myscript" earlier for simplicity):
#!/bin/env python
import sys,os
f = open("cmtest.log","w")
f.write("%s\n" % ' '.join(sys.argv[1:]))
f.close()
try:
    r = open(sys.argv[1],"r").readlines()
except:
    r = "Can't open/read %s\n" % sys.argv[1]
f = open("cmtest.msg","w")
f.write(r)
f.close()

cmtest.log:
/home/pierre/\.claws\-mail/tempfolder/processing/268

cmtest.msg:
Can't open/read /home/pierre/\.claws\-mail/tempfolder/processing/268

Just to be sure we're on the same page, I send a message from another CM
instance and let the receiving CM fetch/filter on its own.

This is the filter which runs both bash and python:
enabled rulename "CMtest" subject matchcase "CMtest" execute "/home/pierre/bin/cmtest.sh \"%F\"" execute "/home/pierre/bin/cmtest.py \"%F\"" move "#mh/Mailbox/inbox/TODO"

Any other ideas?  I'm looking into the escaping..

Cheers,
Pierre

---------------------------------------------------------------------
To unsubscribe, e-mail: claws-mail-users-unsubscribe@...
For additional commands, e-mail: claws-mail-users-help@...


Re: Getting at incoming message contents?

by Pierre Fortin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, 8 Oct 2008 14:57:08 -0400 I wrote:

>I'm looking into the escaping..

How does execute pass to the shell?   bash doesn't escape on input that
I'm aware of and python would require that I "import re" to access
re.escape() -- I verified that the escapes exist in the files in case it
could have been an artifact of "less"...

Puzzled,
Pierre



---------------------------------------------------------------------
To unsubscribe, e-mail: claws-mail-users-unsubscribe@...
For additional commands, e-mail: claws-mail-users-help@...

LightInTheBox - Buy quality products at wholesale price!