5

This is Rakudo Star version 2019.03.1 built on MoarVM version 2019.03 implementing Perl 6.d.

Windows 10

Examples:

1) Error:

shell 'mysqldump -uroot -ppassword asppmr > D:\b\29-09-2019 19-45-18\asppmr.sql';

mysqldump: [Warning] Using a password on the command line interface can be insecure. mysqldump: Couldn't find table: "19-45-18\asppmr.sql" Proc.new(in => IO::Pipe, out => IO::Pipe, err => IO::Pipe, exitcode => 6, signal => 0, pid => 11928, command => ("mysqldump -uroot -ppassword asppmr > D:\b\29-09-2019 19-45-18\asppmr.sql",))

2) Error:

shell 'mysqldump -uroot -ppassword asppmr > "D:\b\29-09-2019 19-45-18\asppmr.sql"';

Синтаксическая ошибка в имени файла, имени папки или метке тома. Proc.new(in => IO::Pipe, out => IO::Pipe, err => IO::Pipe, exitcode => 1, signal => 0, pid => 19372, command => ("mysqldump -uroot -ppassword asppmr > \"D:\b\29-09-2019 19-45-18\asppmr.sql\"",))

3) No error (when there are no spaces in the file path):

so shell 'mysqldump -uroot -ppassword asppmr > D:\b\asppmr.sql';

True

4) cmd.exe no error:

mysqldump -uroot -ppassword asppmr > "D:\b\29-09-2019 19-45-18\asppmr.sql"

5) perl 6 no error:

my $r = q:x/mysqldump -uroot -ppassword asppmr/;
spurt('D:\b\27-09-2019 18-29-12\asppmr.sql', $r);

6) perl 6 no error (if there are no quotes in the file path):

print 'mysql dump: ';
my $d = run 'C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqldump',
    '-uroot',
    '-ppassword',
    'asppmr',
    '--result-file=D:\b\29-09-2019 19-45-18\asppmr.sql',
    :err;

$d.err.slurp(:close); # skip show errors
say $d.exitcode == 0 ?? 'success!' !! 'error!';

mysql dump: success!

Solution: (thanks r4ch)

my $fpath = 'D:\b\29-09-2019 19-45-18\asppmr.sql';
$fpath.subst-mutate(' ', '^ ', :g) if $*DISTRO.is-win;
shell "mysqldump -uroot -ppassword asppmr > {$fpath}";
jjmerelo
  • 22,578
  • 8
  • 40
  • 86
Shniperson
  • 549
  • 4
  • 9

1 Answers1

5

You can try escaping the space in the file path with ^ as suggested in How to escape space in file path in windows run?

gnvk
  • 1,494
  • 12
  • 14