in reply to "Exporting" Terminal Size to Piped Command?

Works for me if I use STDIN or STDERR instead of STDOUT. Those handles are still connected to the terminal the parent script is started from1, while STDOUT (in the child) is connected to the pipe (for which the used TIOCGWINSZ ioctl call is invalid).

___

1 unless you've reopened them to somewhere else in the Perl code, or redirected them to/from a file in the calling shell, of course...

Update:

_____ rcmd.pl _____

#!/usr/bin/perl use Term::Size; my ($col, $row) = Term::Size::chars *STDIN{IO}; print "$col x $row\n";

_____ 699419.pl _____

#!/usr/bin/perl my $rcmd = "./rcmd.pl"; if (open my $cmdh, "$rcmd |") { print <$cmdh>; }

_____

$ ./699419.pl 120 x 50 $ ./699419.pl </dev/null # doesn't work x