My command:
system("start cmd.exe /k C:\\script.pl $arg1 $arg2 $arg3");
is not passing the arguments correctly. What is the correct way to do this?
Thx
The best way to invoke system
is with an array or a list:
my @args = ("start", "cmd.exe", "/k", "C:\\script.pl", $arg1, $arg2, $arg3);
system @args;
system "start", "cmd.exe", "/k", "C:\\script.pl", $arg1, $arg2, $arg3;
Compared with a single string to system
, this saves the complexities of 'how to quote the arguments' because the shell doesn't get a chance to interpret them. On the other hand, if you want the shell to do I/O redirection or piping, you probably won't use this mechanism.
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