1

I have a situation where I need to delete from mailbox (eg. /var/mail/root) messages with specific Message-Id.

Following code works only from console, but I have to do it without user interaction running from cron /etc/crontab.

File: /tmp/clear_spam_test

mutt -f /var/mail/root -e "set alias_file=/var/mail/root" -e "set crypt_use_gpgme=no" -e "push <delete-pattern>~iSomeMessageId@messageid.test\n<sync-mailbox>qy"

I tried many variations

  1. ssh -tt localhost 'bash -s' < /tmp/clear_spam_test

Output:
mutt -f /var/mail/root -e "set alias_file=/var/mail/root" -e "set crypt_use_gpgme=no" -e "push <delete-pattern\>~iSomeMessageId@messageid.test\n\<sync-mailbox\>qy"

echo -e "\nTEST $( whoami ) $0"
exit 0
<n>~iSomeMessageId@messageid.test\n<sync-mailbox>qy"
Error opening terminal: unknown.
TEST root bash
exit
Connection to localhost closed.

  1. ssh -t localhost 'bash -s' < /tmp/clear_spam_test

Output:
Pseudo-terminal will not be allocated because stdin is not a terminal.
No recipients were specified.

  1. ssh -T localhost 'bash -s' < /tmp/clear_spam_test

Output:
No recipients were specified.

  1. ssh -tt $server <<'ENDSSH' echo $(/tmp/clear_spam_test) exit 0 ENDSSH

Output:
Error opening terminal: unknown.
TEST root /tmp/clear_spam_test
logout
Connection to localhost closed.

  1. ssh -t $server <<'ENDSSH' echo $(/tmp/clear_spam_test) exit 0 ENDSSH

Output:
Pseudo-terminal will not be allocated because stdin is not a terminal.
mesg: ttyname failed: Inappropriate ioctl for device
No recipients were specified.
TEST root /tmp/clear_spam_test

  1. ssh -T $server <<'ENDSSH' echo $(/tmp/clear_spam_test) exit 0 ENDSSH

Output:
mesg: ttyname failed: Inappropriate ioctl for device
No recipients were specified.
TEST root /tmp/clear_spam_test

None of it works. I also tried IFS.

  • I still have`t figured it out. Any clue? – Pauli Jun 6 at 8:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.