http://qs321.pair.com?node_id=11749

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

bash$ perl -e '`find > foo`; print \"$!\n\";'

gives me the following output

Bad file descriptor

I can run `find` fine, as long as I don't pipe it or redirect output.

I run the following in Bash version 2.021 with Perl 5.6.0 build 613 on NT 4.00.1381 (4.0) with Service Pack 5.

No file redirection or piping seems to work.

-coyo (running NT due to a past life karma debt, no doubt)

Originally posted as a Categorized Question.

  • Comment on Bad file description for win32/bash/perl combo

Replies are listed 'Best First'.
Re: Bad file description for win32/bash/perl combo
by Coyo (Initiate) on May 16, 2000 at 04:01 UTC
    Too many files!

    Well, I may not have answered the question, but I have found that even putting too large of a string into a backtick operation causes the 'Bad file descriptor' error.

    `wc $lots_of_files`;
    does not work. It can be broken up so to be made to work:
    @lots_of_files = split($lots_of_files);

    $third = $#lots_of_files;

    $a = join(' ', @lots_of_files [0..$third] );

    $a = join(' ', @lots_of_files [1+$third..2*third]);

    $a = join(' ', @lots_of_files [1+2*$third..$#lots_of_files] );

    `wc $a`;

    `wc $b`;

    `wc $c`;

    Well, that seems to work. It doesn't explain why redirection is failing for me in just about all cases though.

    Maybe this is usefull to someone.

    -coyo