Some of this may work, I'll send an url to some expect examples in next reply. You may need to cover another case when mutt finds messages and exit the expect script when that happens.

#!/usr/bin/expect -f
# chmod 755 before use and change path on line 1 if necessary.
spawn > mutt -n -f imap://imap.1blu.de/ \
    -e "set sort=mailbox-order; set confirmappend=no; set delete=yes; push 
'<tag-pattern>.<enter><tag-prefix><save-message>/usr/home/jude/mailboxtmp<enter><sync-mailbox><exit>'"
expect "No hay mensajes"
send "q"

I hope this helps.
On Sun, 4 Dec 2016, Matthias Apitz wrote:

Date: Sun, 4 Dec 2016 10:40:59
From: Matthias Apitz <g...@unixarea.de>
To: mutt-users@mutt.org
Subject: Re: fetching mails with mutt/imap

El d?a Sunday, December 04, 2016 a las 09:06:18AM -0500, Jude DaShiell escribi?:

You might be able to use a little expect in that script to catch and
handle mutt's no mail case when that happens.

The last two lines in the terminal were the script is running say:

---Mutt: imap://imap.1blu.de/INBOX 
[Msgs:0]---(mailbox-order/date)--------------------------(all)---
No hay mensajes.

('No hay mensajes' is Spanish for 'No mails').

How could I catch this in the script and send 'push q'? Can you please
point me to some place in mutt's manual or some examples.

Thanks


mutt -n -f imap://imap.1blu.de/ \
    -e "set sort=mailbox-order; set confirmappend=no; set delete=yes; push 
'<tag-pattern>.<enter><tag-prefix><save-message>/usr/home/guru/mailboxtmp<enter><sync-mailbox><exit>'"

I have added at the end:

... <sync-mailbox><exit>'; push q"

and it seems to do the trick.

        matthias


--

Reply via email to