[TAG] Re: mailto:tag at lists.linuxgazette.net?subject=%20Re%3A%20%5BLG%20120%5D%20help%20wanted%20%233

Benjamin A. Okopnik ben at linuxgazette.net
Mon Nov 14 08:01:40 MSK 2005


On Sun, Nov 13, 2005 at 09:10:35PM -0700, s. keeling wrote:
> Incoming from Benjamin A. Okopnik:
> > 
> > I was wondering. :) I was trying to figure out what that 'print ($2 %
> > \?subject=[a-zA-Z0-9.,-]*)' gadget was supposed to do, and it was
> 
> Modulus of course.  Sheesh.  :-)

In a print statement? "awk"'s not nearly that smart. :)

> > > > echo "$@"|perl -MCGI -we'$q=new CGI(\*STDIN);"@{[$q->Vars=>]}" =~ /mailto:(.*)\?subject\s+(.*)/;system qq[/usr/X11/bin/xterm -e /usr/bin/mutt -s "$2" $1]'
> > > > ''
> > > 
> > > Ow!  OW!?!  
> > 
> > Oh, no! Are *you* the baby Jesus??? I'm so, *SO* sorry...
> 
> Yabut, that's the kind of one-liner that makes python dweebs point and
> say, "So there!"

[laugh] They're welcome to show me how to do it in Python. So there.

> > #!/usr/bin/perl -w
> > # Created by Ben Okopnik on Sun Nov 13 17:24:14 EST 2005
> > use strict;
> 
> Very pretty.  However, called by Firefox, it doesn't seem to get $opts
> right.  It just pops open an rxvt with mutt running in it, no
> To: or Subject: prompts.  Run from the command line, it works
> perfectly with:
> 
>    echo
>    'mailto:tag at lists.linuxgazette.net?subject=%20Re%3A%20%5BLG%20120%5D%20help%20wanted%20%233' | \
>    /usr/local/bin/pinehelper.pl
> 
> but all that's ignored when called by Firefox.  MozEX FAQ confirmed?  :-)

Not at all. I thought you wanted to use it the way you did your "awk"
script, downstream of a pipe from the 'echo'. Firefox calls whatever you
specify with the string as an _argument._ So, if you're going to do it
like that, then just get rid of the while() loop around "@chunks" and
grab the 1st arg instead:

``
#!/usr/bin/perl -w
# Created by Ben Okopnik on Sun Nov 13 17:24:14 EST 2005
use strict;

my ( @chunks, $k, $v, %header, $opts);

@chunks = split /[?&]/, shift;

for ( @chunks ){
        ( $k, $v ) = split /[:=]/;
	# Cheap-ass entity conversion
        ( $header{ $k } = $v ) =~ s/%(..)/pack("H2",$1)/eg;
}

# Define Mutt switches for any headers we're interested in
$opts = qq[ -s "$header{subject}" ] if exists $header{subject};
$opts .= $header{mailto};

exec "/usr/X11/bin/xterm -T Mutt -e /usr/bin/mutt $opts"
	or die "Big Bad System Error!!!";
''

ItWorksForMe. :)


* Ben Okopnik * Editor-in-Chief, Linux Gazette * http://linuxgazette.net *





More information about the TAG mailing list