I'm playing with run
on Windows. Trying it with dir
doesn't work but maybe I'm missing something:
put '-' x 70;
my $p1 = run 'dir', :out;
put "exit code: {$p1.exitcode}";
put $p1.out.slurp(:close);
put '-' x 70;
my $p2 = Proc.new: :out;
put "exit code: {$p2.exitcode}";
$p2.spawn: 'dir';
$p2.out.slurp(:close).say;
The output is just the rule and exit code lines:
----------------------------------------------------------------------
exit code: 1
----------------------------------------------------------------------
exit code: 1
The dir
works fine with shell
but that's a different way of doing things. I could do this but that's going through the shell which run
wants to avoid:
my $p1 = run 'cmd.exe', '/C', 'dir', :out;
This is expected behavour given that dir
is a shell command, not an executable.
If you hit ⊞ Win+R to open the run dialog and enter dir
, it will fail for the same reason (unless you happen to have an unrelated executable dir.exe
somewhere in your path).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With