Is there a nice google-like dictionary/direction/search-engine offline service?
I was using info@askmenow.com from blackberry for a while but now they go commercial way
and cut that service

Код: Выделить всё
~/.procmailrc:
###############################################################
# Send Google queries by mail.
ASKGOOGLE="google@rogers.com"
QUERY=`formail -zxSubject \
| /usr/local/bin/decode_header url`
:0
* $^To: .*(${ASKGOOGLE})
| { formail -rt -I "Content-type: text/html; charset=utf-8";\
echo "$(date +"%Y-%m-%d %H:%M") \"${QUERY}\"" \
| /usr/local/bin/decode_url >> /var/log/google.log ;\
wget -q -U "" -O - \
"http://www.google.ca/pda?ie=utf-8&oe=utf-8&q=${QUERY}" ;\
} | $SENDMAIL -oi -t
Код: Выделить всё
/usr/local/bin/decode_header:
#! /usr/bin/perl -w
# Header decoding copied from http://benya.com/procmail/.
use warnings;
use strict;
use Text::Iconv;
use FileHandle;
use IPC::Open2;
my $ocs = shift || "utf-8";
my $ocs_url = 0;
if ($ocs eq "url") {
$ocs = "utf-8";
$ocs_url = 1;
}
while (<>) {
chomp;
s/^[ \t]//;
foreach (split(/(=[?].*?[?][BQ][?].*?[?]=)/i)) {
my $convtxt = $_;
if (my ($charset, $encoding, $txt) = /=[?](.*?)[?]([bq])[?](.*?)[?]=/i) {
$encoding =~ tr/[BQ]/[bq]/;
my $pid = open2(\*CHILD_OUT, \*CHILD_IN, "mimencode -u -$encoding");
print CHILD_IN "$txt\n";
close CHILD_IN;
my $txtdec = <CHILD_OUT>;
close CHILD_OUT;
chomp($txtdec);
# print "Decoding \"$txtdec\" from charset $charset\n";
my $converter = Text::Iconv->new($charset, $ocs);
$converter->raise_error(0);
$convtxt = $converter->convert($txtdec);
}
if ($ocs_url) {
$convtxt =~ s/([\W])/"%" . uc(sprintf("%2.2x",ord($1)))/eg;
}
print $convtxt;
}
}
Код: Выделить всё
/usr/local/bin/decode_url:
#! /usr/bin/perl -w
# URL decoding from http://glennf.com/writing/hexadecimal.url.encoding.html
use warnings;
use strict;
# use Carp ();
# local $SIG{__WARN__} = \&Carp::cluck;
use Text::Iconv;
my $cs = shift || "koi8-r";
while (<>) {
chomp;
s/%([a-fA-F0-9]{2})/chr(hex($1))/eg;
my $converter = Text::Iconv->new("utf-8", $cs);
$converter->raise_error(0);
my $convtxt = $converter->convert($_);
print "$convtxt\n";
}
Thanks!Ильгиз писал(а):How long should the response take? Can your PDA read HTML email?
I set up a procmail "recipe" that will respond to google@rogers.com based on the query in the subject line, but it takes up to 10 minutes to forward and poll the message. Feel free to use this responder.
Код: Выделить всё
~/.procmailrc: ############################################################### # Send Google queries by mail. ASKGOOGLE="google@rogers.com" QUERY=`formail -zxSubject \ | /usr/local/bin/decode_header url` :0 * $^To: .*(${ASKGOOGLE}) | { formail -rt -I "Content-type: text/html; charset=utf-8";\ echo "$(date +"%Y-%m-%d %H:%M") "${QUERY}"" \ | /usr/local/bin/decode_url >> /var/log/google.log ;\ wget -q -U "" -O - \ "http://www.google.ca/pda?ie=utf-8&oe=utf-8&q=${QUERY}" ;\ } | $SENDMAIL -oi -t
Код: Выделить всё
/usr/local/bin/decode_header: #! /usr/bin/perl -w # Header decoding copied from http://benya.com/procmail/. use warnings; use strict; use Text::Iconv; use FileHandle; use IPC::Open2; my $ocs = shift || "utf-8"; my $ocs_url = 0; if ($ocs eq "url") { $ocs = "utf-8"; $ocs_url = 1; } while (<>) { chomp; s/^[ \t]//; foreach (split(/(=[?].*?[?][BQ][?].*?[?]=)/i)) { my $convtxt = $_; if (my ($charset, $encoding, $txt) = /=[?](.*?)[?]([bq])[?](.*?)[?]=/i) { $encoding =~ tr/[BQ]/[bq]/; my $pid = open2(\*CHILD_OUT, \*CHILD_IN, "mimencode -u -$encoding"); print CHILD_IN "$txt\n"; close CHILD_IN; my $txtdec = <CHILD_OUT>; close CHILD_OUT; chomp($txtdec); # print "Decoding "$txtdec" from charset $charset\n"; my $converter = Text::Iconv->new($charset, $ocs); $converter->raise_error(0); $convtxt = $converter->convert($txtdec); } if ($ocs_url) { $convtxt =~ s/([\W])/"%" . uc(sprintf("%2.2x",ord($1)))/eg; } print $convtxt; } }
(Last corrected: 2006-07-05 16:52)Код: Выделить всё
/usr/local/bin/decode_url: #! /usr/bin/perl -w # URL decoding from http://glennf.com/writing/hexadecimal.url.encoding.html use warnings; use strict; # use Carp (); # local $SIG{__WARN__} = \&Carp::cluck; use Text::Iconv; my $cs = shift || "koi8-r"; while (<>) { chomp; s/%([a-fA-F0-9]{2})/chr(hex($1))/eg; my $converter = Text::Iconv->new("utf-8", $cs); $converter->raise_error(0); my $convtxt = $converter->convert($_); print "$convtxt\n"; }