Re: From Jiang: question about dialog and mutt
> Mutt doesn't lock the display when it calls sendmail--it has no means
> to do so--so this isn't a matter of mutt not surrendering the display.
> This appears to be a problem with your script. Not being able to see
> or try your script, it's hard to tell.
>
> This is just a hunch, but since the script's stdin is connected to a
> pipe from which it receives the message text, you may have to tell
> dialog to use /dev/tty as its stdin and/or stdout, something like
> this:
>
> dialog --yesno "Can you see me now?" 20 20 < /dev/tty > /dev/tty
>
> HTH,
> Gary
Thanks a lot Gary. TTY is indeed the problem. Once I set it to be the
correct one, it works. I attach my modified script in this email just in
case anyone wants to use text console instead of zenity in "rev_"(?)'s
script on http://wiki.mutt.org/?ConfigTricks/CheckAttach
My script require $TTY to be set to correct value
Jiang
#!/bin/bash
SENDMAIL=/usr/sbin/sendmail
###
# this script uses a GUI app called "zenity" to ask for confirmation,
# if not in GUI, just let it pass. If you want TUI (not GUI) query,
# which means you replace "zenity" with something else, then
# drop this DISPLAY check.
###
#if [ -z "$DISPLAY" ]; then
# exec $SENDMAIL "$@"
#fi
###
# save msg in file to re-use it for multiple tests
###
t=`mktemp -t mutt.XXXXXX` || exit 2
cat > $t
cat $t > new
###
# define tests for: anything you can think of can be done.
# the return code of last exec'ed cmd is used in final decision below
###
function multipart {
grep -q '^Content-Type: multipart' $t
}
function word-attach {
grep -v '^>' $t | egrep -q 'attach*|Attach*'
}
###
# query function must return "true" to let the msg pass.
###
function ask {
# zenity --question --title 'mutt' --text 'Did you include the attachment
(if you wanted to)?'
#DIALOG=${DIALOG=dialog}
#DIALOG=${DIALOG=$HOME/bin/dialog}
#terminal=`tty`
#terminal=/dev/pts/7
#echo $terminal >> new
DIALOG=${DIALOG=dialog}
$DIALOG --defaultno --title "mutt" --clear \
--yesno "Have you added your attachment, if you want one?" 10 30 < $TTY
> $TTY
# --yesno "Have you added your attachment?" 10 30
#$DIALOG --title "mutt" \
# --yesno "Have you added your attachment?" 10 30
#case $? in
# 0)
# echo "true";;
# 1)
# echo "false";;
# 255)
# echo "ESC pressed.";;
#esac
}
###
# FINAL DECISION:
# chain series of functions, use ! || && for logic connections,
# see "man $SHELL" for more possibilites like grouping, dependencies.
###
if multipart || ! word-attach || ask; then
$SENDMAIL "$@" < $t
status=$?
else
status=1
fi
clear
rm -f $t
exit $status