LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-08-2013, 04:05 PM   #1
stephsanol
LQ Newbie
 
Registered: Jul 2013
Posts: 4

Rep: Reputation: Disabled
Mutt command and body message reading


Hi there!
I'm pretty newbie at shell scripting, and I need to read my email inbox through shell commands. So far I've been able to see my inbox in the terminal when I type the command mutt. But I need to create a shell script that can filter my messages by subject (in the mutt command mode I type "/wordfilter") but in the shell script this command is not recognized. And after finding the message with certain subject I need to interact with the message body, maybe copying it to a txt file so I can read it easily.

Any ideas?

Thanks
 
Old 08-09-2013, 10:44 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Have you tried the push command to pass a key sequence to mutt? For example
Code:
mutt -e 'push /wordfilter\n'
will open an interactive session showing the result of the search. Suppose you want to read the message directly, add another \n (as you pressed enter in interactive mode).
Code:
mutt -e 'push /wordfilter\n\n'
At this point you may want to pass more complicated sequences of keys/commands to accomplish your task. Suppose you want to save the message in a file and quit mutt to avoid interaction:
Code:
mutt -e 'push <enter-command>"unset wait_key"\n/wordfilter\n<pipe-message>"cat > message.txt"\n<quit>'
The pipe-message command is used to pipe the content of the message to an external command. In this case you can save it to a file using cat (as shown). Note that the first part (in grey) is necessary to avoid the "Press any key to continue..." message that usually comes out after the execution of pipe-message. For a complete reference to mutt commands, see the official documentation here: http://www.mutt.org/doc/manual/manual-6.html.
 
1 members found this post helpful.
Old 08-09-2013, 11:06 AM   #3
stephsanol
LQ Newbie
 
Registered: Jul 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
It worked perfectly

Thank you colucix!! That is exactly what I needed! Yeah, I've been searching the answer to my questions in the mutt manual but there are so many shell commands (non mutt) that I still don't recognize. I'm working on it Thanks a lot.
 
  


Reply

Tags
email, mutt, shell scripting



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Send email body through mutt santhosh_cv Programming 2 07-18-2012 05:29 AM
How to add Date/Time to the message body? robertspycher Programming 1 09-09-2009 03:52 AM
Procmail - body of message twantrd Linux - Software 1 12-19-2006 07:31 PM
SMTP logging without including the body of the message jspencereds Linux - Networking 0 04-09-2004 11:33 AM
KMail: execute command depending on message body linuxfond Linux - Newbie 0 01-31-2004 07:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:21 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration