* [Comm] KMail filter help @ 2008-04-13 17:15 Yurkovsky Andrey 2008-04-13 17:28 ` Алексей Синицын 2008-04-13 18:39 ` Alexander Yereschenko 0 siblings, 2 replies; 14+ messages in thread From: Yurkovsky Andrey @ 2008-04-13 17:15 UTC (permalink / raw) To: community Мне хотелось бы сохранять отчеты о расходах от провайдера приходящие на e-mail в файл. Для этих целей я собирался сделать скрипт затем фильтр в почтовике "Пропустить через конвейер". Пока у меня на выходе получается только пустой файл. Содержимое скрипта такое: #!/bin/bash LOCATION="/mnt/main/lib/finance/internet" FLINE=`cat $1|grep -i -n \<html\>|head -c 2` ELINE=`cat $1|grep -i -n \</html\>|head -c 2` TDATA=`cat $1|grep -A $(echo $[$ELINE-$FLINE]) \<html\>` echo $TDATA|iconv -f koi8-r -t cp1251 >\ $LOCATION/server-`date '+%d-%m-%y'`.html Если скрипту подсунуть сохраненное письмо, то все получается как надо, а через фильтр - нет. Что я делаю не так, подскажите. -- Yurkovsky Andrey ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Comm] KMail filter help 2008-04-13 17:15 [Comm] KMail filter help Yurkovsky Andrey @ 2008-04-13 17:28 ` Алексей Синицын 2008-04-14 12:25 ` Yurkovsky Andrey 2008-04-13 18:39 ` Alexander Yereschenko 1 sibling, 1 reply; 14+ messages in thread From: Алексей Синицын @ 2008-04-13 17:28 UTC (permalink / raw) To: ALT Linux Community general discussions 13.04.08, Yurkovsky Andrey<anyr@tut.by> написал(а): > Мне хотелось бы сохранять отчеты о расходах от провайдера приходящие на > e-mail в файл. Для этих целей я собирался сделать скрипт затем фильтр в > почтовике "Пропустить через конвейер". Пока у меня на выходе получается > только пустой файл. Содержимое скрипта такое: > > #!/bin/bash > LOCATION="/mnt/main/lib/finance/internet" > FLINE=`cat $1|grep -i -n \<html\>|head -c 2` > ELINE=`cat $1|grep -i -n \</html\>|head -c 2` > TDATA=`cat $1|grep -A $(echo $[$ELINE-$FLINE]) \<html\>` > echo $TDATA|iconv -f koi8-r -t cp1251 >\ > $LOCATION/server-`date '+%d-%m-%y'`.html > > Если скрипту подсунуть сохраненное письмо, то все получается как надо, а > через фильтр - нет. Что я делаю не так, подскажите. > > Если вместо script mail указать echo script mail > ~/testfile.txt то в файле будет ожидаемая команда? ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Comm] KMail filter help 2008-04-13 17:28 ` Алексей Синицын @ 2008-04-14 12:25 ` Yurkovsky Andrey 2008-04-14 12:51 ` Алексей Синицын 0 siblings, 1 reply; 14+ messages in thread From: Yurkovsky Andrey @ 2008-04-14 12:25 UTC (permalink / raw) To: community Алексей Синицын wrote: > Если вместо > script mail > указать > echo script mail > ~/testfile.txt > то в файле будет ожидаемая команда? Да -- Yurkovsky Andrey ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Comm] KMail filter help 2008-04-14 12:25 ` Yurkovsky Andrey @ 2008-04-14 12:51 ` Алексей Синицын 0 siblings, 0 replies; 14+ messages in thread From: Алексей Синицын @ 2008-04-14 12:51 UTC (permalink / raw) To: ALT Linux Community general discussions 14.04.08, Yurkovsky Andrey<anyr@tut.by> написал(а): > Алексей Синицын wrote: > > > Если вместо > > script mail > > указать > > echo script mail > ~/testfile.txt > > то в файле будет ожидаемая команда? > > Да > А если еще попробовать cat mail > ~/testfile.txt ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Comm] KMail filter help 2008-04-13 17:15 [Comm] KMail filter help Yurkovsky Andrey 2008-04-13 17:28 ` Алексей Синицын @ 2008-04-13 18:39 ` Alexander Yereschenko 2008-04-14 12:34 ` Yurkovsky Andrey 1 sibling, 1 reply; 14+ messages in thread From: Alexander Yereschenko @ 2008-04-13 18:39 UTC (permalink / raw) To: ALT Linux Community general discussions Доброе! В сообщении от Sunday 13 April 2008 20:15:03 Yurkovsky Andrey написал(а): > Мне хотелось бы сохранять отчеты о расходах от провайдера приходящие на > e-mail в файл. Для этих целей я собирался сделать скрипт затем фильтр в > почтовике "Пропустить через конвейер". Пока у меня на выходе получается > только пустой файл. Содержимое скрипта такое: > > #!/bin/bash > LOCATION="/mnt/main/lib/finance/internet" > FLINE=`cat $1|grep -i -n \<html\>|head -c 2` > ELINE=`cat $1|grep -i -n \</html\>|head -c 2` > TDATA=`cat $1|grep -A $(echo $[$ELINE-$FLINE]) \<html\>` > echo $TDATA|iconv -f koi8-r -t cp1251 >\ > $LOCATION/server-`date '+%d-%m-%y'`.html > > Если скрипту подсунуть сохраненное письмо, то все получается как надо, а > через фильтр - нет. Что я делаю не так, подскажите. Какова ваша строка запуска скрипта, которая прописана в KMail ? Ибо есть ряд ньюансов (см. ниже). И кстати, вероятно для ваших нужд больше подойдет не "пропустить через конвеер" , а "выполнить команду", ибо исходное письмо, как я понимаю, изменять не надо. Из справки KMail: ====== Выполнить команду Выполняется некоторая программа, но сообщение не изменяется. Указывайте полный путь к программе, которую нужно выполнить. KMail не будет откликаться до завершения программы. Передавать программе части письма можно через командную строку: %0, %1 и т.д. заменяются файлами, содержащими части сообщения. В большинстве сообщений %0 представляет собственно текст сообщения, %1 – первое вложение и т.д. Кроме того, сообщение целиком передаётся на стандартный ввод (stdin) программы. Каждый аргумент вида %{foo} заменяется заголовком foo. Внимание На данный момент это работает только тогда, когда сообщение содержит по меньшей мере одно вложение. Если же нет, обычно не будет работать даже %0. Подсказка Вы можете вводить сколь угодно сложные команды, т.к. KMail использует оболочку для выполнения команд. Поэтому в KMail будет работать даже такая команда: uudecode -o $(mktemp kmail-uudecoded.XXXXXX) && echo $'\a' Пропустить через конвейер Сообщение передаётся по конвейеру заданной программе. Если программа что-либо выводит, всё сообщение (включая заголовки) будет заменено выводом программы. Если программа ничего не выводит или завершается с кодом возврата, не равным нулю, сообщение не меняется. Требуется указать полный путь к программе. В командной строке производятся те же замены (%n, %{foo}), что и при выполнении действия выполнить команду. Внимание Используйте это действие с осторожностью, т.к. ваши сообщения могут быть испорчены, если вызываемая программа возвратит мусор или дополнительные строки. ====== -- Alexander ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Comm] KMail filter help 2008-04-13 18:39 ` Alexander Yereschenko @ 2008-04-14 12:34 ` Yurkovsky Andrey 2008-04-14 13:01 ` Alexander Yereschenko 0 siblings, 1 reply; 14+ messages in thread From: Yurkovsky Andrey @ 2008-04-14 12:34 UTC (permalink / raw) To: community Alexander Yereschenko wrote: > Доброе! > В сообщении от Sunday 13 April 2008 20:15:03 Yurkovsky Andrey написал(а): >> Мне хотелось бы сохранять отчеты о расходах от провайдера приходящие на >> e-mail в файл. Для этих целей я собирался сделать скрипт затем фильтр в >> почтовике "Пропустить через конвейер". Пока у меня на выходе получается >> только пустой файл. Содержимое скрипта такое: >> >> #!/bin/bash >> LOCATION="/mnt/main/lib/finance/internet" >> FLINE=`cat $1|grep -i -n \<html\>|head -c 2` >> ELINE=`cat $1|grep -i -n \</html\>|head -c 2` >> TDATA=`cat $1|grep -A $(echo $[$ELINE-$FLINE]) \<html\>` >> echo $TDATA|iconv -f koi8-r -t cp1251 >\ >> $LOCATION/server-`date '+%d-%m-%y'`.html >> >> Если скрипту подсунуть сохраненное письмо, то все получается как надо, а >> через фильтр - нет. Что я делаю не так, подскажите. > > Какова ваша строка запуска скрипта, которая прописана в KMail ? Ибо есть > ряд ньюансов (см. ниже). И кстати, вероятно для ваших нужд больше подойдет > не "пропустить через конвеер" , а "выполнить команду", ибо исходное > письмо, как я понимаю, изменять не надо. Пробовал и так и сяк. В качестве команды писал: просто адрес/скрипт, затем то же и %1, затем то же, но с %0. Пробовал менять в самом скрипте %1 на %0 результат один и тот же - создается файл с нужным именем, но в нем пусто. > > Из справки KMail: > ====== > Выполнить команду > > Выполняется некоторая программа, но сообщение не изменяется. Указывайте > полный путь к программе, которую нужно выполнить. KMail не будет > откликаться до завершения программы. Передавать программе части письма > можно через командную строку: %0, %1 и т.д. заменяются файлами, > содержащими части сообщения. В большинстве сообщений %0 представляет > собственно текст сообщения, %1 – первое вложение и т.д. Кроме того, > сообщение целиком передаётся на стандартный ввод (stdin) программы. Каждый > аргумент вида %{foo} заменяется заголовком foo. > > Внимание > На данный момент это работает только тогда, когда сообщение содержит по > меньшей мере одно вложение. Если же нет, обычно не будет работать даже %0. Т.е. если в письме нет вложений то необходимо писать %0, или в любом случае при отсутствии вложений скрипт не будет работать? > Подсказка > Вы можете вводить сколь угодно сложные команды, т.к. KMail использует > оболочку для выполнения команд. Поэтому в KMail будет работать даже такая > команда: uudecode -o $(mktemp kmail-uudecoded.XXXXXX) && echo $'\a' > -- > Alexander > _______________________________________________ > community mailing list > community@lists.altlinux.org > https://lists.altlinux.org/mailman/listinfo/community -- Yurkovsky Andrey ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Comm] KMail filter help 2008-04-14 12:34 ` Yurkovsky Andrey @ 2008-04-14 13:01 ` Alexander Yereschenko 2008-04-14 18:08 ` Yurkovsky Andrey 0 siblings, 1 reply; 14+ messages in thread From: Alexander Yereschenko @ 2008-04-14 13:01 UTC (permalink / raw) To: ALT Linux Community general discussions Доброе! В сообщении от 14 апреля 2008 Yurkovsky Andrey написал(a): > > Из справки KMail: > > Внимание > > На данный момент это работает только тогда, когда сообщение содержит по > > меньшей мере одно вложение. Если же нет, обычно не будет работать даже > > %0. > > Т.е. если в письме нет вложений то необходимо писать %0, или в любом случае > при отсутствии вложений скрипт не будет работать? Как я понял, если нет вложений, то и в %0 может ничего не быть, что видимо и происходит. Лучше в скрипте читать тело письма из stdin - это гарантировано работает. -- Alexander ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Comm] KMail filter help 2008-04-14 13:01 ` Alexander Yereschenko @ 2008-04-14 18:08 ` Yurkovsky Andrey 2008-04-15 8:57 ` Андрей Черепанов 0 siblings, 1 reply; 14+ messages in thread From: Yurkovsky Andrey @ 2008-04-14 18:08 UTC (permalink / raw) To: community Alexander Yereschenko wrote: > Лучше в скрипте читать тело письма из stdin - это гарантировано работает. Замечательно, а подскажите как? -- Yurkovsky Andrey ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Comm] KMail filter help 2008-04-14 18:08 ` Yurkovsky Andrey @ 2008-04-15 8:57 ` Андрей Черепанов 2008-04-15 11:46 ` Yurkovsky Andrey 0 siblings, 1 reply; 14+ messages in thread From: Андрей Черепанов @ 2008-04-15 8:57 UTC (permalink / raw) To: ALT Linux Community general discussions 14 апреля 2008 Yurkovsky Andrey написал: > Alexander Yereschenko wrote: > > Лучше в скрипте читать тело письма из stdin - это гарантировано работает. > > Замечательно, а подскажите как? content=`cat` -- Андрей Черепанов ALT Linux cas@altlinux.ru ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Comm] KMail filter help 2008-04-15 8:57 ` Андрей Черепанов @ 2008-04-15 11:46 ` Yurkovsky Andrey 2008-04-15 12:08 ` Serge 2008-04-15 12:41 ` Андрей Черепанов 0 siblings, 2 replies; 14+ messages in thread From: Yurkovsky Andrey @ 2008-04-15 11:46 UTC (permalink / raw) To: community Андрей Черепанов wrote: > content=`cat` Уж извините... но все равно пока не понимаю куда это приткнуть... -- Yurkovsky Andrey ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Comm] KMail filter help 2008-04-15 11:46 ` Yurkovsky Andrey @ 2008-04-15 12:08 ` Serge 2008-04-15 12:41 ` Андрей Черепанов 1 sibling, 0 replies; 14+ messages in thread From: Serge @ 2008-04-15 12:08 UTC (permalink / raw) To: ALT Linux Community general discussions В сообщении от Tuesday 15 April 2008 14:46:50 Yurkovsky Andrey написал(а): > Андрей Черепанов wrote: > > content=`cat` > > Уж извините... но все равно пока не понимаю куда это приткнуть... я так понимаю в тело Вашего скрипта ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Comm] KMail filter help 2008-04-15 11:46 ` Yurkovsky Andrey 2008-04-15 12:08 ` Serge @ 2008-04-15 12:41 ` Андрей Черепанов 2008-04-15 12:56 ` Yurkovsky Andrey 1 sibling, 1 reply; 14+ messages in thread From: Андрей Черепанов @ 2008-04-15 12:41 UTC (permalink / raw) To: ALT Linux Community general discussions 15 апреля 2008 Yurkovsky Andrey написал: > Андрей Черепанов wrote: > > content=`cat` > > Уж извините... но все равно пока не понимаю куда это приткнуть... Эта строчка помещает ввод из stdin в переменную $content вашего скрипта После этого делайте echo "$content" вместо echo $1 -- Андрей Черепанов ALT Linux cas@altlinux.ru ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Comm] KMail filter help 2008-04-15 12:41 ` Андрей Черепанов @ 2008-04-15 12:56 ` Yurkovsky Andrey 2008-04-15 14:15 ` Michael Shigorin 0 siblings, 1 reply; 14+ messages in thread From: Yurkovsky Andrey @ 2008-04-15 12:56 UTC (permalink / raw) To: community Андрей Черепанов wrote: > Эта строчка помещает ввод из stdin в переменную $content вашего скрипта > После этого делайте echo "$content" вместо echo $1 > Все, получилось, все большое спасибо. -- Yurkovsky Andrey ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Comm] KMail filter help 2008-04-15 12:56 ` Yurkovsky Andrey @ 2008-04-15 14:15 ` Michael Shigorin 0 siblings, 0 replies; 14+ messages in thread From: Michael Shigorin @ 2008-04-15 14:15 UTC (permalink / raw) To: community On Tue, Apr 15, 2008 at 03:56:16PM +0300, Yurkovsky Andrey wrote: > > Эта строчка помещает ввод из stdin в переменную $content > > вашего скрипта После этого делайте echo "$content" вместо > > echo $1 > Все, получилось, все большое спасибо. Только лучше квотить: content="`cat`" или content="$(cat $(ls))" -- ---- WBR, Michael Shigorin <mike@altlinux.ru> ------ Linux.Kiev http://www.linux.kiev.ua/ ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2008-04-15 14:15 UTC | newest] Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2008-04-13 17:15 [Comm] KMail filter help Yurkovsky Andrey 2008-04-13 17:28 ` Алексей Синицын 2008-04-14 12:25 ` Yurkovsky Andrey 2008-04-14 12:51 ` Алексей Синицын 2008-04-13 18:39 ` Alexander Yereschenko 2008-04-14 12:34 ` Yurkovsky Andrey 2008-04-14 13:01 ` Alexander Yereschenko 2008-04-14 18:08 ` Yurkovsky Andrey 2008-04-15 8:57 ` Андрей Черепанов 2008-04-15 11:46 ` Yurkovsky Andrey 2008-04-15 12:08 ` Serge 2008-04-15 12:41 ` Андрей Черепанов 2008-04-15 12:56 ` Yurkovsky Andrey 2008-04-15 14:15 ` Michael Shigorin
ALT Linux Community general discussions This inbox may be cloned and mirrored by anyone: git clone --mirror http://lore.altlinux.org/community/0 community/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 community community/ http://lore.altlinux.org/community \ mandrake-russian@linuxteam.iplabs.ru community@lists.altlinux.org community@lists.altlinux.ru community@lists.altlinux.com public-inbox-index community Example config snippet for mirrors. Newsgroup available over NNTP: nntp://lore.altlinux.org/org.altlinux.lists.community AGPL code for this site: git clone https://public-inbox.org/public-inbox.git