There is an option beep_new in the Mutt's configuration variables, which causes Mutt to issue a beep when new email arrives. Also there is <shell_esc> command, which executes a command in internal shell. Is there a way to cause Mutt to execute some user defined action (shell command) when new email arrives? Maybe <pipe-message> can help? (One can use <pipe-message> in a configuration file to call a shell command. Is there a way to do this in running Mutt?)
EDIT: as per Glenn advice, a script from Mutt can be called by configuring the custom status format in the .muttrc file:
set status_format="/some/script.sh '%r %f (%L) |"
But I can't figure out how to use this for new email detection, since the "New mail in..." notification appears on the command line, and not in the status line. And if the email arrived to a mailbox that is not the current, then the status line doesn't change at all.
EDIT 2: OK, the %b variable in the status_format did the thing.
Mutt can't do this (at least not without some workaround).
NeoMutt can: see it's new_mail_command.
You can achieve that through inotifywait as the mutt manual suggests.
Install inotify
(example for Debian based distros: apt install inotify-tools)
Watch mutt folder and run your script
(bash script example:
while : ; do inotifywait -e modify -r ~/.mutt ; /my_facy/script ; done
Related
I'm trying to run a sendmail command in a Red-hat Linux environment on a bash shell script through a cronjob. I can run this script successfully when it is ran manually and every other job within the shell runs correctly other than the mailing part.I have never used sendmail and am not sure if I need to restructure how it is being presented.
I have tried mail and mailx. I am able to send the emails but the log file contain many weird characters that it put the text format into a att00001.bin attachment on the email which I do not want. The sendmail command seems to be the only one that doesn't send an attachment when ran manually. Other cron jobs works correctly and are able to send emails they just do not have the special characters in the log file.
echo '##################################################'
date
echo '##################################################'
#Run Script and write to log file
/comp/gfb281m.sh > /usr/local/bin/oracle/getload/getload.log 2>&1
#Send log file to developer group
(echo "Subject:GetLoad Shell"; echo; cat
/usr/local/bin/oracle/getload/getload.log) | sendmail -v
exampleEmail#outlook.com exampleEmail2#mail.mil
When ran this cron job should send the contents of the getload.log file to a group a of users.
Fixed the issue thanks to another source. I was not using the sendmail's full path. I was just stating "| sendmail -v email" and not sendmails full path which was "/usr/sbin/sendmail" for me. Not sure if links are allowed here but below is where I found the answer.
https://www.unix.com/red-hat/271632-bash-sendmail-command-not-found.html
crontab sets PATH to /usr/bin:/bin. To avoid typing absolute command names like /etc/sbin/sendmail you can set up the PATH in you crontab:
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
*/30 * * * * sendmail user#example.com%subject: Sample email%%Email body%
I use an alert command which notifies me whenever a bash comand runs (e.g. ./long_running_task ; alert) will send an alert whenever long_running_task completes. I sometimes forget to write ; alert at the end of my commands, so I'm wondering if there's a way to automatically trigger this--like with some sort of shim. The answers here seem to only work if I want to run alert before long_running_task, which won't help in my case.
Is there a way to call the alert command after every shell command that I run from the terminal?
Found out you can do this by setting the PROMPT_COMMAND variable. In my bashrc, I added this line: export PROMPT_COMMAND='alert'.
We have another piece of software saving data into an rtf file. We need to pull that data out and email it as the body of the Email. In SCO Unix we were able to use this:
mailx –s “Subject of email” email#example.com </text.rtf
But now that we are running Redhat the mailx package used is an entirely different package and will only attach the file as an attachment. Any help on this subject is greatly appreciated.
We had a similar problem and solved it by faking mailx by a shell script. Change $PATH so that your "mailx" shell script is found first.
In this script we use sendEmail (Perl script, look here http://caspian.dotconf.net/menu/Software/SendEmail/) to send the mail:
sendEmail $ABSAUTH $(echo \-u "$(echo "$1"|sed -e 's/^-s//')") -t $2
We ended up using the mail command instead.
$ mail –s “Subject of email” email#example.com < /text.rtf
some documentation can be found at https://www.binarytides.com/linux-mail-command-examples/ or using the "man mail" command.
I wanna write the output of various commands as an email.
I tried this:
#!/bin/bash
(echo $(date); echo $(top);sudo apt-get update && sudo apt-get upgrade -y) | mail -s "Updated!" xxxxxxxxxxx#gmail.com -a "From: UpdateNotify<xxxxxxxx#gmail.com>";
The script is infinite. :/
How can I do that? I need the date,top output and the update logs in one email.
That's the right way to do it, the issue is with echo $(top). top is an interactive application so never returns.
You should look to use ps instead to list the current processes running.
jas_raj answer is correct, however if you like top's output you can run in batch mode: top -bn 1 this will make top exit right after it runs once.
have a look at cron-apt and nullmailer to send mails after system update.
Hi I'm trying to run a script that calls xclip in order to have a string ready to paste when i connect to the internet.
I have a script /etc/network/if-up.d/script that does execute when connecting (i make him post a date in a file succesfuly ) but the xclip instruction seems not to work, there's nothing to paste. If i call this script manually by typing /etc/network/if-up.d/script in a console it works perfectly.
If i try to launch a zenity message it also don't appeare when connecting. Again if i do it by hand it appeares.
Then I have a expect script that calls matlab (console mode), if I execute it manually it works but if i call it from cron it freezees when calling the script.
It's driving me crasy since it seems that only certain commands in a script can be executed when the system calls them automaticaly.
I'v tryed to call the instructions with nohup instruction & but still misses
This is working as designed, you search around and will see compliated ways to resolve this issue, or you can use xmessage as I describe here: Using Zenity in a root incron job to display message to currently logged in user
Easy option 1: xmessage (in the script)
MSSG="/tmp/mssg-file-${RANDOM}"
echo -e " MESSAGE \n ==========\n Done with task, YEY. " > ${MSSG}
xmessage -center -file ${MSSG} -display :0.0
[[ -s ${MSSG} ]] && rm -f ${MSSG}
Easy option 2: set the DISPLAY (then should work)
export DISPLAY=:0 && /usr/bin/somedirectory/somecommand
question is answered here for cron :
http://ubuntuforums.org/archive/index.php/t-105250.html
and here for if-up network :
Bash script not working properly when run automatically