Posts Tagged ‘windows’

Neat solution for deploying/running Perl Apps on Windows:

… [share] your production Perl installation, with all the packages required by all your apps correctly installed. And place the top-level .pl scripts (or some placeholder .cmd files if some local setup is required), within that installation. Then your users can run those applications from that shared installation.

Read Full Post »

My question about how windows works without fork got pointers to two useful Windows perl modules in the comments:

Spawning External Programs

(from dagolden) See Win32::Job or just use system(1, $cmd, @args)

Creating Daemons

(from Christian Walde) Use Win32::Detached

What I was really wondering about was how reliable software was written without fork. What do I mean by that?

What is the difference between?




If the child thread misbehaves – exits, dumps core, leaks memory, or whatever, that’s bad for the parent. Child processes can’t wreak quite so much havoc.

Presumably the solution adopted in Window is don’t do stuff in threads that causes them to accidentally exit [the whole process], dump core or leak memory.

Read Full Post »

Interesting. Strawberry Perl installed Authen::SASL::Perl without any problem. You’re right. That is not unexpected. Once you get away from POSIX signals and processes, most pure perl is pretty portable.

cd c:/strawberry/cpan/build/Authen-SASL-2.1401-V48Oe3/t
perl digest_md5.t
ok 1 - new
ok 2 - sasl mechanism
ok 3 - conn mechanism
ok 4 - client_start
ok 5 - we need extra steps

Which line is saying we need extra steps?

is($sasl->mechanism, 'DIGEST-MD5', 'sasl mechanism');

my $conn = $sasl->client_new("ldap","localhost", "noplaintext noanonymous");

is($conn->mechanism, 'DIGEST-MD5', 'conn mechanism');

is($conn->client_start, '', 'client_start');
ok  $conn->need_step, "we need extra steps";

Hang on a minute, wasn’t it need_step() that was failing in Arc? Maybe it is fixable after all if I just move from the XS authentication to the pure perl implementation.

Read Full Post »

Enablers and Obstructors

A tail about the Windows Unix shells and MSYS path mangling

I am aware of three libre "Unix" shells on Windows, Cygwin (bash), MSYS (bash) and the shell that comes with UnixUtils (zsh). Out of all of these, only the MSYS shell mangles the paths. And sometimes, even though it can be surprising, path mangling is a good thing.

$ perl -e 'print $ARGV[0], "\n"' '/c/xxx:/c/yyy'
$ echo '/c/xxx:/c/yyy'

Okay, that was a bit unrealistic (although something similar bit me for a couple of hours and indirectly led to this post). Let’s have a look at $PATH.

$ perl -e 'print $ARGV[0], "\n"' "$PATH"
c:\MinGW\bin;c:\strawberry\perl\bin;c:\msys\1.0\bin;c:\Windows\system32;c:\Windows;c:\Windows\System32\Wbem;c:\Program Files\Java\jdk1.6.0_15\bin;c:\Program Files\TortoiseHg;c:\packages\cygwin\bin;c:\packages\lib
$ echo $PATH
/c/MinGW/bin:/c/strawberry/perl/bin:/c/msys/1.0/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Program Files/Java/jdk1.6.0_15/bin:/c/Program Files/TortoiseHg:/c/packages/cygwin/bin:/c/packages/lib

Fun stuff eh?

I believe the heuristic that is used is that native MSYS apps use unix style paths and other apps use windows style paths.

Larry Wall – An Enabler

I really like Larry Wall. He didn’t decide ahead of time how people were going to use Perl. He provided the various features, observed what people were doing with them and then made it easier to do typical tasks. He enabled useage that he hadn’t necessarily foreseen.


[With Perl], I was trying to encourage what I call diagonal thinking. Traditionally computer languages try to be as orthogonal as possible, meaning their features are at all at right angles to each other, metaphorically speaking. The problem with that is that people don’t solve problems that way. If I’m in one corner of a park and the restrooms are in the opposite corner of the park, I don’t walk due east and then due north. I go northeast — unless there’s a pond in the way or something.

I am told that when they built the University of California at Irvine, they did not put in any sidewalks the first year. Next year they came back and looked at where all the cow trails were in the grass and put the sidewalks there. Perl is designed the same way. It’s not just a random collection of features. It’s a bunch of features that look like a decent way to get from here to there. If you look at the diagram of an airline, it’s a network. Perl is a network of features… It’s more like glue than it is like Legos.

Counter example – An Obstructor

Contrast that with Keith talking about a proposed feature for MSYS 1.0.12 in this post. (Emphasis mine)

I agree that there is a need to do something, but if I’m understanding you correctly, you propose implementing some sort of environment variable hook, which will switch path name translation ON or OFF globally? IMO, that simply will not cut the mustard. If path name translation is globally OFF, then MSYS will be emasculated, becoming nothing more than a limited clone of an obsolete version of Cygwin; might just as well ditch it, and use current Cygwin instead.

For me, the principal reason to choose MSYS over Cygwin is the automatic path name translation feature. Take that away, and MSYS is dead; I will use Cygwin instead. (Except, of course, that you make it optional, so I keep the path translation turned ON, and entirely ignore whatever effort you invest in providing the option).

No, we do not need a global method of disabling path name translation

Who is we referring to here? I would find a global method of disabling path name translation useful for two out of the three uses I have for a Unix shell on Windows and I don’t imagine I’m unusual:

  1. An tool for building libraries or executables from a tarball
  2. A superior interactive alternative to cmd.exe.
  3. A superior alternative to cmd.exe for writing batch scripts.

And I’m not thrilled about needing to install cygwin just to get a usable shell. Fortunately, there is an alternative. I can set up zsh from UnxUtils to use the MSYS executables and at a pinch it can provide a reasonable facimile of bash.

This is my .zshrc.




# -- Remove the paths to various perl versions

PATH=`$PERL -e 'print join(";", grep { lc($_) !~ /perl/ }
                      split /;/, $ENV{PATH})'`

# -- Remove the duplicate paths (and ".")

PATH=`$PERL -e '%h = ("" => 1, "." => 1 );
                print join(";", grep { ! $h{$_}++ }
                split /;/, $ENV{PATH})'`

export PATH

The default $TERM is dumb which isn’t very helpful.

TERM=rxvt ; export TERM
EDITOR='emacsclientw' ; export EDITOR

Set tab completion to work in the way I’m used to.

set -o AUTO_LIST

I haven’t managed to get history between sessions working yet. Not sure what the problem with this is …


HISTFILE=$HOME/.zsh_history ; export HISTFILE

And this is pretty close to my standard postamble.


cd $HOME

HOST=`echo $HOST | tr '[:upper:]' '[:lower:]'`

PS1="$USER@$HOST \$ "

One word of warning: although this works fine on Windows XP, on Vista, even with XP compatibility enabled it sometimes crashes with a c:/home/jared/.zshrc: fork failed: no error [48] error. When this happens, sourcing zshrc manually with . ~/.zshrc works.

Read Full Post »