in reply to Execute command with spaces in perl
Your quoting does not match how the Windows shell (cmd.exe) processes quotes.
cmd.exe does not recognize a backslash before a space as the intention to quote that space. A working invocation of firefox.exe could be:
my $ff_exe = q{C:\\Program Files\\Mozilla Firefox\\firefox.exe}; my @cmd = ($ff_exe, '--version'); my $shell_command = join " ", # separate by spaces map { /\s/ ? qq{"$_"} : $_ } # enclose in double q +uotes if needed @cmd; print $shell_command;
Note that under Windows, the --version command line switch does not output anything.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Execute command with spaces in perl
by pryrt (Abbot) on Aug 27, 2018 at 15:52 UTC |