I have to pass a command with its arguments in a scheduled task, while separating the arguments from the command. I used:
split(/(?=\s-)/)
to do this, but it won't work when the argument is not passed as -arg format.
Example of commands can be passed in format:
"ping http://www.google.com" here url is argument
"abc-abc -V"
"abc-abc -L c:\\folder name\\test.log"
'"C:\\Program Files\\example\\program.exe" -arg1 -arg2'
"C:\\Program Files\\example\\program.exe"
To make this more clear these commands are not passed as command line argument which can get in ARGV
The command gets set in command property which accepts input in string format
command '"C:\\Program Files\\example\\program.exe" -arg1 -arg2'
"C:\\Program Files\\example\\program.exe"/(?=\s-)/. (2) Why won't that example work by just splitting on space? Even in the comment above, I don't see how that will fail? (3) There's probably no need to "reinvent the wheel" here with some regex. There is a standard convention in almost all languages: The command line arguments are known asARGV, which you can access in ruby as a constant. Ruby also providesARGF, which works as a data stream.