We had a fun situation at work this week, when our old and weary Exchange server gave up the ghost and died. We’d been planning to migrate it to a new server anyway, but we weren’t planning on doing it this week. Oh well, it was an incentive to get the move out of the way.
I’d already written a Perl script to migrate all of the clients to the new server. Not very elegant, it just sat on a machine with Domain Admin rights, and performed a remote registry edit of each client on the network, replacing the Exchange server settings in the registry with the details of the replacement server. I’d done a few test runs using ActivePerl under XP, and it had worked fine.
Unfortunately when we realised we had to migrate now, I didn’t have an XP machine to hand, and obviously the Windows administration tools that the Perl script required weren’t available on my Debian workstation. So we ran it on another Windows machine with Perl installed, and it failed.
A few minutes of frantic debugging later, we concluded that somehow the backslashes in the UNC paths were getting munged when Perl was passing them to the registry client via backticks (we needed to capture the output). This machine happened to be running Perl built for Cygwin, rather than ActiveState.
One install of ActivePerl later, the script was running along happily. I guess there’s a subtle (but big enough) difference between Perl for Cygwin and ActivePerl in the way they handle subprocesses run from CMD. You learn something new every day. But I think I’ll just stick to Perl on Linux…