Misha has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks

Sorry for asking again but am really stuck with this. I need to collect output of Perl modules installation. I am running on UNIX environment.
I am installing Perl modules (via Perl script) by using following command:
system (" perl -MCPAN -e 'install Bundle::Snapshot_2007_07_23_00' ")
The installation completed successfully.
In order to collect logs and see the output on the screen (because installation of some models is interactive) I did following changes:
system (" perl -MCPAN -e 'install Bundle::Snapshot_2007_07_23_00' | './1.pl' ")
when 1.pl is very simple:

while ($tmp = <STDIN> || $tmp = <STDERR>)
{
print $tmp;
write_to_log($tmp);
}

Now have 3 problems:
1. The interactive questions which were during installation are missing.
2. The program stuck during the modules installation.
3. The output is different from what I have before and some important parts are missing.

How I can solve those problems? Is there other way to collect Perl module installation logs?

Many thanks
  • Comment on How to get installtion Perl modules log?

Replies are listed 'Best First'.
Re: How to get installtion Perl modules log?
by moritz (Cardinal) on Oct 23, 2007 at 13:58 UTC
    Why didn't you use script as I previously suggested?

    You current approach doesn't log everything because some things might be written to STDERR which the redirect doesn't capture.

    Also CPAN might write directly to the terminal (instead of STDIN/STDOUT) which could be the reason why you don't see it.

    script takes care of such things, which is why I suggested it.

    By the way: your perl script 1.pl has a unix equivalent, it's called tee

    Update: Another solution could use Expect.

    A reply falls below the community's threshold of quality. You may see it by logging in.