Tuesday, November 27, 2007

Windows to serve? :-(

"Platform independent" indeed is a motto for professional developers, which means quality softwares should be able to move freely between platforms with great ease, not sorrow. And my recent experience proved it right, but in another field, the web service development.

I'm the author of several junky databases and on Monday this week I got a task to "transplant" them on a ThinkPad X31, which runs a windows XP, which is authentic home edition, and which guarantees to be, eh, slow.

After complaining for a couple of hours, I finally settled down to work and analyze the situation I was facing. (Those databases were wrote on a Linux platform, and running on Linux platform. They were never intended to have even a single relationship with Microsoft products!)

Any way, I got to do the task, and two days later now it's nearly finished. I think I should write some lines here, as memoir in case I met similar tasks!!

1. MySQL issue
Mysql databases on linux platform can be dumped out and used to rebuild an identical one on windows like following:
c:\mysql -uroot dbname < dbname.dump
dbname.dump is a dump file generated by mysqldump.
There seemed to be version incompatibility as the mysql on windows is 4.0.1 while on Linux it is 4.1. When dumping on windows, mysql complains unrecognized word like:
"ENGINE=MyISAM DEFAULT CHARSET=latin1;"
They appear after table creation SQL statements. I directly replaced them to "TYPE=MyISAM;" and it simply works.

2. File path in Perl
The header in all Perl CGI program has to be changed to:
#!c:\perl\bin\perl.exe
and absolute directories has to be dealt with care. In open file, DIRs can be specified safely with slash, while in system calls (I frequently call "move"!) backslash has to be used.
For DIRs with space in it (eg, "Program Files"), double quote mark is sometimes necessary. However note following are valid:
require 'C:\Program Files\Apache Software Foundation\Apache2.2\cgi-bin\easygo\code.pl';
my $dir = 'c:\program files\apache software foundation\apache2.2';
system "move script\\funky_stuff \"$dir\\htdocs\"";

3. File path in R
The program needs to call R in batch mode and do some file input/output. On windows, R accepts slash to indicate directories, but space need to be converted by backslash. So to indicate a file, write following in Perl:
$dirInR .= "c:/program\\ files/aaa/bbb/";

No comments: