in reply to Re^3: Execute command with spaces in perl
in thread Execute command with spaces in perl

For your second example the output on Windows is:

List form of pipe open not implemented at C:\usr\pm\pipe2.pl line 5.

This is discussed at this node as mentioned by naveenp5.

Replies are listed 'Best First'.
Re^5: Execute command with spaces in perl
by pryrt (Abbot) on Aug 27, 2018 at 15:50 UTC

    That appears to have been fixed since 2011:

    C:\usr\local\share\PassThru\perl>perl -Mwarnings -Mstrict -MConfig -le + "my $cmd = q|C:\Program Files\Mozilla Firefox\firefox.exe|; open my +$fh, '-|', $cmd, '--version' or die $!; m y $out = do { local $/; <$fh> }; close $fh or die $! ? $! : qq(\$?=$?) +; print $out; print $Config{myuname}" Mozilla Firefox 61.0.2 Win32 strawberry-perl 5.26.2.1 #1 Sun Apr 15 13:52:49 2018 x64

    Trying to narrow it down a bit, using berrybrew to help me, it appears it was sometime between v5.20 and v5.26:

    C:\usr\local\share\PassThru\perl>berrybrew use 5.10.1_32,5.16.3_64,5.2 +0.3_64,5.26.1_32 perl-5.10.1_32 ============== Microsoft Windows [Version 10.0.16299.611] (c) 2017 Microsoft Corporation. All rights reserved. <berrybrew use 5.10.1_32>: run "exit" leave this environment C:\usr\local\share\PassThru\perl>perl -Mwarnings -Mstrict -MConfig -le + "my $cmd = q|C:\Program Files\Mozilla Firefox\firefox.exe|; open my +$fh, '-|', $cmd, '--version' or die $!; m y $out = do { local $/; <$fh> }; close $fh or die $! ? $! : qq(\$?=$?) +; print $out; print $Config{myuname}" List form of pipe open not implemented at -e line 1. <berrybrew use 5.10.1_32>: run "exit" leave this environment C:\usr\local\share\PassThru\perl>exit Exiting <berrybrew use 5.10.1_32> perl-5.16.3_64 ============== Microsoft Windows [Version 10.0.16299.611] (c) 2017 Microsoft Corporation. All rights reserved. <berrybrew use 5.16.3_64>: run "exit" leave this environment C:\usr\local\share\PassThru\perl>perl -Mwarnings -Mstrict -MConfig -le + "my $cmd = q|C:\Program Files\Mozilla Firefox\firefox.exe|; open my +$fh, '-|', $cmd, '--version' or die $!; m y $out = do { local $/; <$fh> }; close $fh or die $! ? $! : qq(\$?=$?) +; print $out; print $Config{myuname}" List form of pipe open not implemented at -e line 1. <berrybrew use 5.16.3_64>: run "exit" leave this environment C:\usr\local\share\PassThru\perl>exit Exiting <berrybrew use 5.16.3_64> perl-5.20.3_64 ============== Microsoft Windows [Version 10.0.16299.611] (c) 2017 Microsoft Corporation. All rights reserved. <berrybrew use 5.20.3_64>: run "exit" leave this environment C:\usr\local\share\PassThru\perl>perl -Mwarnings -Mstrict -MConfig -le + "my $cmd = q|C:\Program Files\Mozilla Firefox\firefox.exe|; open my +$fh, '-|', $cmd, '--version' or die $!; m y $out = do { local $/; <$fh> }; close $fh or die $! ? $! : qq(\$?=$?) +; print $out; print $Config{myuname}" List form of pipe open not implemented at -e line 1. <berrybrew use 5.20.3_64>: run "exit" leave this environment C:\usr\local\share\PassThru\perl>exit Exiting <berrybrew use 5.20.3_64> perl-5.26.1_32 ============== Microsoft Windows [Version 10.0.16299.611] (c) 2017 Microsoft Corporation. All rights reserved. <berrybrew use 5.26.1_32>: run "exit" leave this environment C:\usr\local\share\PassThru\perl>perl -Mwarnings -Mstrict -MConfig -le + "my $cmd = q|C:\Program Files\Mozilla Firefox\firefox.exe|; open my +$fh, '-|', $cmd, '--version' or die $!; m y $out = do { local $/; <$fh> }; close $fh or die $! ? $! : qq(\$?=$?) +; print $out; print $Config{myuname}" Mozilla Firefox 61.0.2 Win32 strawberry-perl-no64 5.26.1.1 #1 Sun Sep 24 11:38:56 2017 i386 <berrybrew use 5.26.1_32>: run "exit" leave this environment C:\usr\local\share\PassThru\perl>exit Exiting <berrybrew use 5.26.1_32>

      Ahahhaa! My error was in just trying it from the command line instead of piping the output of firefox.exe to make it output something:

      Without the pipe, it outputs nothing:

      >"c:\Program Files (x86)\Mozilla Firefox\firefox.exe" --version

      With the pipe, it outputs the version information, as it should:

      >"c:\Program Files (x86)\Mozilla Firefox\firefox.exe" --version | more Mozilla Firefox 61.0.2
Re^5: Execute command with spaces in perl (updated)
by haukex (Archbishop) on Aug 27, 2018 at 15:47 UTC
    List form of pipe open not implemented

    Yes, my update, which I made shortly after posting that node, mentions it: the list from of piped open wasn't implemented on Windows until Perl v5.22. I don't see where naveenp5 mentions that particular error, though? Update: Oh, I see it now (the URL of 902198). I understood that comment to refer to the string pipe, not the error message, but it is a hint that the OP may be on a Perl older than v5.22 - another reason to use a module instead :-)

      My perl version is "v5.10.0 built for MSWin32-x64-multi-thread". How do I get that firefox --version working in this older version ?

        My perl version is "v5.10.0 built for MSWin32-x64-multi-thread".

        Please note that Perl 5.10.0 is more than 10 years old, I recommend considering an upgrade.

        How do I get that firefox --version working in this older version ?

        As I said, I strongly recommend using one of the modules I mentioned. Yes, even you can use CPAN, and at least Strawberry Perl 5.10.0 includes IPC::Run3.