Computers: November 2003 Archives
This little script will print out Apple event debugging info.
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__
#!/bin/bashSuch as:
AEDebug=1 AEDebugSends=1 AEDebugReceives=1 AEDebugVerbose=1 AEDebugOSL=1 "$@"
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:
The Ventures playing Frosty the Snowman. You remember The Ventures, from the Hawaii Five-O theme song.
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.
.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?
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?
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:
(Note: it may take time for the release to propagate to the various download mirrors.)
Changes:
* v1.16, Wednesday, November 19, 2003Posted using release by brian d foy.
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
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:
(Note: it may take time for the release to propagate to the various download mirrors.)
Changes:
* v1.10, Wednesday, November 19, 2003Posted using release by brian d foy.
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.
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). ]
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
#!/usr/local/bin/perlI call this from crontab (note that it sets up the ssh-agent vars first):
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;
}
*/5 * * * * sourceAnd 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./Users/pudge/.bash_ssh_env; /Users/pudge/bin/ssh-lock
#!/usr/local/bin/perlMmmmm, glue.
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);
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/shNow I can do:
perl -MMac::Glue=:all -MData::Dumper -l -e 'splice(@ARGV, 1, 1); $g = new Mac::Glue shift;$g->ERRORS(1);' -e "$2" "$@"
glue iTunes 'print $g->prop("player state")->get'
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:
(Note: it may take time for the release to propagate to the various download mirrors.)
Changes:
* v1.4, November 18, 2003Posted using release by brian d foy.
Fix reaping to not hang waiting for all children to close
Don't require an argument, as we could just be reading from STDIN
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.
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:
(Note: it may take time for the release to propagate to the various download mirrors.)
Changes:
* v1.15, Tuesday, November 18, 2003Posted using release by brian d foy.
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).
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.
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.
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.
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/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");
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.
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.
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.
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.
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:
Speaking of death, did Neo die? Did I miss something?
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?