Thursday, March 1, 2007

interactive support for si_psh

Today I improved my favorite distributed shell si_psh (that is part of SystemImager) adding the interactive support.

I need it for the BCX cluster when I have to run multiple commands on the same subset of nodes. Without the interactive support I used to edit the command line of the previous command in the shell, but with long commands this is not practice enough...

I discovered also that ssh (maybe via glibc, dunno...) knows when it has the stdin opened on a terminal or not and if it doesn't find a valid terminal it's not possible to catch the stderr inside a perl wrapper script! The problem is that when si_psh runs interactively stdin is not opened in the terminal, but it's opened inside the perl script, to get the user commands (like a typical shell). And so I wasn't able to get the stderr of the spawned ssh sessions...

It's possible to workaround spawning the ssh process via exec. For example in this case @out contains both stdout and stderr:

my @out = `exec 2>&1 ssh ...`;

And this doesn't work (@out doesn't contain the stderr):

my @out = `ssh ... 2>&1`;

No comments: