Computers: November 2003 Archives

aedebug

| | Comments (0)
This little script will print out Apple event debugging info.

#!/bin/bash
AEDebug=1 AEDebugSends=1 AEDebugReceives=1 AEDebugVerbose=1 AEDebugOSL=1 "$@"

Such as:

aedebug osascript -e 'tell app "Finder" to activate'

Returns, in part:

AE2000 (918): Sending an event:
------oo start of event oo------ { 1 } 'aevt': misc/actv (ppc ){ return id: 60162053 (0x3960005) transaction id: 0 (0x0) interaction level: 64 (0x40) reply required: 1 (0x1) remote: 0 (0x0) target: { 2 } 'psn ': 8 bytes { { 0x0, 0xe0001 } (Finder) } optional attributes: { 1 } 'reco': - 2 items { key 'subj' - { -1 } 'null': null descriptor key 'csig' - { 1 } 'magn': 4 bytes { 65536l (0x10000) } } event data: { 1 } 'aevt': - 0 items { } } ------oo end of event oo------ AE2000 (918): Received an event reply: ------oo start of event oo------ { 1 } 'aevt': aevt/ansr (ppc ){ return id: 60162053 (0x3960005) transaction id: 0 (0x0) interaction level: 112 (0x70) reply required: 0 (0x0) remote: 0 (0x0) target: { 1 } 'psn ': 8 bytes { { 0x0, 0xe0001 } (Finder) } optional attributes: < empty record > event data: { 1 } 'aevt': - 0 items { } } ------oo end of event oo------ With the glue script I can do this, to get a similar result: aedebug glue Finder '$g->activate' __URLLLLL__

Christmas Music

| | Comments (0)

Major Panther Bugfix

| | Comments (0)
Has anyone else noticed that file sharing works a lot better under Mac OS X 10.3? I have not had any problems unmounting file servers. Before, I often could not unmount because the Finder was busy doing stuff, so I would have to force quit the Finder. Or if I slept and awoke, I could not unmount at all, and accessing it might freeze up everything. Panther fixes all this. use.perl.org
.command file support is broken for me in Panther.

I have a command file on my Desktop, call it "foo.command". Terminal.app is not running. I double click it, it launches Terminal.app, it runs the command in a new window. Fine. I do it again, fine. As much as I want to, keep doing it, it works.

But then ... it stops working. For no reason. I try again 20 seconds later, and it no longer works. I click, but no window opens. I don't do anything but simply wait. What is UP?

I even completely removed my com.apple.Terminal.plist file, so it is not my prefs, it seems. What is UP? use.perl.org

Mac-Glue-1.16 Released

| | Comments (0)
Mac-Glue-1.16 has been released. Download it from the CPAN or SF.net.

(Note: it may take time for the release to propagate to the various download mirrors.)
Changes:

* v1.16, Wednesday, November 19, 2003
 
   There's a bug in perl 5.8.0-5.8.2 whereby -- depending on how your perl
   is compiled -- the value of $^E (see the Mac::Glue docs for details)
   is modified when accessed.  This patch helps minimize the effect, so
   at least the value is reliable right after a Mac::Glue event call.
   This change makes the value of $^E more reliable even without the bug
   in perl.
 
   The problem still exists in using Mac::Errors and probably other code.
   It will be fixed in perl 5.8.3 and later.  Here's a patch to your perl
   if you want to fix it locally:
 
   http://nntp.x.perl.org/group/perl.perl5.porters/8 5393

Posted using release by brian d foy. use.perl.org

Mac-AppleEvents-Simple-1.10 Released

| | Comments (0)
Mac-AppleEvents-Simple-1.10 has been released. Download it from the CPAN or SF.net.

(Note: it may take time for the release to propagate to the various download mirrors.)
Changes:

* v1.10, Wednesday, November 19, 2003
 
   Fixes for $^E bug in perl 5.8.x (and make $^E handling more robust).
 
   Change pack_pid() to use actual PID instead of converting to PSN,
   using typeKernelProcessID instead of typeProcessSerialNumber.

Posted using release by brian d foy. use.perl.org

Mac::Carbon Released

| | Comments (0)
Mac::Carbon has been released. Download it from the CPAN or SF.net.

(Note: it may take time for the release to propagate to the various download mirrors.)
Changes:

* v0.63, 19 November 2003
 
   Add typeApplicationBundleID target type constant.

Posted using release by brian d foy. use.perl.org

Stupid Mac::Glue/SSH Tricks

| | Comments (0)
You may have read in my journal about how I have my ssh-agent set up on Mac OS X; briefly, I use a login plugin called SSHAgentStartup which creates an ssh-agent before logging in, and sets up the environment in ~/.MacOSX/environment.plist, so it is global to all my apps. I have it also create a ~/.bash_ssh_env file that I can source from my bash init files.

Then I have a startup script that calls ssh-add without a terminal attached (ssh-add </dev/null works, though in this case it is a startup AppleScript that just does do shell script "/usr/bin/ssh-add" in a try/end try block), with SSH_ASKPASS set to the path of an app called SSHPassKey, which retrieves my ssh passphrase from the Keychain. Since the Keychain is unlocked upon logging in, and the ssh-agent is run and its environment vars are set before this script is run, this automatically adds my keys to the ssh-agent without any extra user interaction.

So I just log in, and this is all set up for me: a global ssh-agent for all my GUI apps and shells, with my keys added to the agent and ready to go.

The only problem I have with this setup is that I like to have my Keychain lock automatically after inactivity or sleep, for security's sake; but this does not also disable the ssh-agent. So there's a little security issue there that I wanted to address.

So, this ssh-lock script was born. It checks to see if the Keychain named for the current user is locked, and if so, it removes my identities from the ssh-agent. Mmmm, security!

[ Keychain Scripting is a little Faceless Background App; it will launch, but it won't show up in the Dock, and it will stay open. The glue for this app is created automatically when you install Mac::Glue, along with several other FBAs that reside in the /System/Library/ScriptingAdditions folder (such as URL Access Scripting, which is pretty much useless from Perl, since we have LWP). ]

#!/usr/local/bin/perl
use warnings;
use strict;
 
use Mac::Glue;
 
my $ssh_add = '/usr/bin/ssh-add';
 
my $kc = new Mac::Glue 'Keychain_Scripting';
my $locked = $kc->prop(locked => keychain => scalar getpwuid($<));
 
if ($ENV{SSH_AGENT_PID} && kill 0, $ENV{SSH_AGENT_PID}) {
    system($ssh_add, '-d') if $locked->get;
}

I call this from crontab (note that it sets up the ssh-agent vars first):

*/5   * * * * source /Users/pudge/.bash_ssh_env; /Users/pudge/bin/ssh-lock

And I also wrote a little front-end to ssh, that checks to see if my ssh-agent has my identities in it, and if not, adds them automatically, just like the startup script does, with no user interaction, unless the Keychain is locked, in which case SSHPassKey will prompt me for the Keychain password. Then, it just goes ahead and calls ssh.

#!/usr/local/bin/perl
use warnings;
use strict;
 
my $ssh = '/usr/bin/ssh';
my $ssh_add = '/usr/bin/ssh-add';
 
if ($ENV{SSH_AGENT_PID} && kill 0, $ENV{SSH_AGENT_PID}) {
        if (`$ssh_add -l` =~ /no identities/) {
                `$ssh_add </dev/null`;
        }
}
 
system($ssh, @ARGV);

Mmmmm, glue. use.perl.org

Stupid Mac::Glue Tricks

| | Comments (0)
I find one-liners in Mac::Glue to be annoying.

perl -MMac::Glue=:all -le '$itunes = new Mac::Glue "iTunes"; print $itunes->prop("player state")->get'

It's a mouthful, and mostly boilerplate. So how about this little shell script? Standardize on one glue var name, $g, and suck in Data::Dumper, which I commonly use, and:

#!/bin/sh
perl -MMac::Glue=:all -MData::Dumper -l -e 'splice(@ARGV, 1, 1); $g = new Mac::Glue shift;$g->ERRORS(1);' -e "$2" "$@"

Now I can do:

glue iTunes 'print $g->prop("player state")->get'

use.perl.org

cenotaph-1.4 Released

| | Comments (0)
cenotaph-1.4 has been released. Download it from SF.net.

(Note: it may take time for the release to propagate to the various download mirrors.)
Changes:

* v1.4, November 18, 2003
 
   Fix reaping to not hang waiting for all children to close
 
   Don't require an argument, as we could just be reading from STDIN

Posted using release by brian d foy. use.perl.org

Terminal.app and Window Names

| | Comments (0)
Right now, the name of my frontmost window in Terminal.app is "pudge@slashdot-nfs-1:/usr/local/src — ssh". How does Terminal.app know I am logged into that machine, and am in that directory? I do know "pudge@slashdot-nfs-1:/usr/local/src" is called the "custom title" portion of the name, but I do not know how it is being set automatically. use.perl.org

Mac-Glue-1.15 Released

| | Comments (0)
Mac-Glue-1.15 has been released. Download it from the CPAN or SF.net.

(Note: it may take time for the release to propagate to the various download mirrors.)
Changes:

* v1.15, Tuesday, November 18, 2003
 
   Make "set" event look at direct object's type instead of defaulting
   to guessing between plain numeric/text (should be less need for
   param_type() now).
 
   Make guesses for numeric/text also check for floats.
 
   Where there are multiple types for something, get the first one we
   know how to deal with.
 
   Add more numeric types.
 
   Fix typeUnicodeText to automatically encode text to UTF-16 as
   expexted (if Encode module is available).

Posted using release by brian d foy. use.perl.org
We've been having a problem with hung httpds, bad data sent to clients, and other mischief since we moved OSDN sites (NewsForge, OSDN.com, Slashdot, etc.) to a new network. Turns out the problem was Apache 1.3.28, which has a nasty bug that allows Apache to steal fds. So Apache would open an fd to a client, and the MySQL libraries would think it is a MySQL server and ping it, and all hell would break lose.

Thanks to Radu Greab for the fix, Theory for pointing out the fix (he experienced similar issues with DBD::Pg), and Rudy Lippan for pointing me to Theory. use.perl.org

Stupid Mac::Glue Tricks

| | Comments (0)
I use this with XChat Aqua. Note that I create the objects outside the handler: XChat smartly caches the script, so the objects are created once. That, combined with only loading the modules once, significantly decreases the execution time, to nearly nil.

Also, I use IsRunning() to see if I am running iTunes locally; if so, it uses that, and if not, it uses the other box running in the house.

I had to install Mac::Glue etc. for the system perl, which I rarely use, but the plugin library is only compatible with that one. But I made the directory containing the glues a symlink to my local perl's (`sudo ln -s /usr/local/lib/perl5/site_perl/5.8.0/Mac/Glue/glue s /Library/Perl/5.8.1/Mac/Glues/` or whatever). Those are just Storable + MLDBM, I don't need separate copies of them.

#!/usr/bin/perl
 
use strict;
use Mac::Apps::Launch;
use Mac::Glue;
 
my $itunes = new Mac::Glue 'iTunes';
 
my $track = $itunes->prop('current track');
 
my $name = $track->prop('name');
my $artist = $track->prop('artist');
my $album = $track->prop('album');
 
sub np {
    if (IsRunning($itunes->{ID})) {
        $itunes->ADDRESS;
    } else {
        $itunes->ADDRESS(eppc => iTunes => 'sweeney.local');
    }
 
    my @data = map { $_->get } ($name, $artist, $album);
    my $str = $data[0];
    return 0 unless $str;
    $str = "$str - $data[1]" if $data[1];
    $str = "$str ($data[2])" if $data[2];
    IRC::command("NP: $str");
    return 1;
}
 
IRC::register("np", "1.0", "", "");
IRC::add_command_handler("np", "np");

use.perl.org

More Toys

| | Comments (0)
I bought a Roomba for Jennifer for Christmas (from iRobot Store). Next up is robotic dogs that poop in the corner of the yard where I tell them to. use.perl.org

The Two Towers DVDs

| | Comments (0)
It happened again. Last year, we got the FotR extended edition DVDs before the release date. This year, today, we picked up tTT, a few days before Tuesday's release date. It was at BJ's wholesale club last year, and at a local Blockbuster this year.

Last year I said the sound was good, but the picture wasn't great on my TV. This year, I have a large widescreen HD monitor, and better speakers. Totally sweet. use.perl.org

mod_gzip Calling Perl Handlers Twice

| | Comments (0)
With mod_gzip installed, my PerlAccessHandler handlers get called twice. I dislike this. Does anyone know what the heck is going on and how to fix it? use.perl.org

Stupid Mac::Glue Tricks

| | Comments (0)

perl -MMac::Glue -e '$s = new Mac::Glue "Safari"; $d = $s->obj(document => 1); $s->do_javascript("window.location.reload()", in => $d), sleep 60 while 1'

Yes, I am using Perl to talk to Safari via Apple events to have it execute some JavaScript. It's a bit boggling to me that there's no "reload" event in Safari's dictionary, but, whatever. use.perl.org
I've heard a lot of people say they disliked the new Matrix movie. I thought it was great, better than Reloaded. I enjoyed it almost as much as the original. It had much better pacing than Reloaded, and much better action.

I cringed when they left Agent Smith (now as a human) alone with the doctor. "Hm, we suspect he is insane and killed several of our crews, let's leave him alone with the doctor!" Couldn't they have spared one or two guards?

I also hated the scene where Trinity died. She should have died quicker, or Neo should have left her there. People are dying in Zion, pal, get moving. Here's how I would have rewritten the scene:

TRINITY: Kiss me.

They kiss.

TRINITY: Now go.

NEO: I can't leave you.

TRINITY: I'm going to die, and you can't wait, now go!

NEO: I can't!

TRINITY: Urk!

Trinity dies.

Neo holds her and yells.

NEO: Nooooooooo!

Neo suspects something, leans over and puts his ear to Trinity's chest.

NEO: Hey, you're not dead!

TRINITY: Well, what the hell do you want me to do? I can't just die, and you're too much of a wuss to go save everyone until I do. Here, give me that shard of glass, I'll do myself!

NEO: Nooooooooo!

Trinity reaches for glass, Neo tries to grab it from her, they struggle, she ends up with glass through heart, she dies.

NEO: Nooooooooo!

Everyone in Zion, having run into the temple, is overrun by the sentinels. They die.


Speaking of death, did Neo die? Did I miss something? use.perl.org

Mac-OSA-Simple-1.08 Released

| | Comments (0)
Mac-OSA-Simple-1.08 has been released. Download it from the CPAN or SF.net.

(Note: it may take time for the release to propagate to the various download mirrors.)
Changes:

* v1.08, Sunday, November 9, 2003
 
   Oops, forgot Mac::AppleEvents::Simple in PREREQ

Posted using release by brian d foy. use.perl.org

Mac-OSA-Simple-1.07 Released

| | Comments (0)
Mac-OSA-Simple-1.07 has been released. Download it from the CPAN or SF.net.

(Note: it may take time for the release to propagate to the various download mirrors.)
Changes:

* v1.07, Sunday, November 9, 2003
 
   Fix for changed file format in Panther's Script Editor.

Posted using release by brian d foy. use.perl.org
Mac-AppleEvents-Simple-1.09 has been released. Download it from the CPAN or SF.net.

(Note: it may take time for the release to propagate to the various download mirrors.)
Changes:

* v1.09, Sunday, November 2, 2003
 
   Oops, spelled URI "URL" in Makefile.PL.

Posted using release by brian d foy. use.perl.org
<pudge/*> (pronounced "PudgeGlob") is thousands of posts over many years by Pudge.

"It is the common fate of the indolent to see their rights become a prey to the active. The condition upon which God hath given liberty to man is eternal vigilance; which condition if he break, servitude is at once the consequence of his crime and the punishment of his guilt."

About this Archive

This page is a archive of entries in the Computers category from November 2003.

Computers: October 2003 is the previous archive.

Computers: December 2003 is the next archive.

Find recent content on the main index or look in the archives to find all content.