I’m trying to check if a specific port is currently busy so i came up with the following:
${output} Run Process netstat -ano | find “LISTENING” | find “${DEFAULT_PORT}”
should contain ${output.stdout} ${DEFAULT_PORT}
The problem is with the double quotation marks around the LISTENING and the variable, because when the test is executed the following command is executed
with backslashes appearing before each quotation mark.
I tried to use backslash, single and double quotation marks to escape this but it didn’t help, is there is a way to make these backslashes disappear? or to achieve the same goal using a different code?
Often on this forum the problem is not enough spaces, but in this case I thing your problem is too many spaces
Have a look at Specifying command and arguments, because you have 2 spaces between netstat and -ano, etc run process is treating all your arguments as separate arguments.
I’ll draw your attention to this sentence from the documentation:
This makes usage convenient and also allows these keywords to automatically escape possible spaces and other special characters in commands and arguments
What I think you want is to use the single string method (only 1 space between the command and each argument)
When running processes in shell, it is also possible to give the whole command to execute as a single string. The command can then contain multiple commands to be run together. When using this approach, the caller is responsible on escaping.
Thanks for your help, I had the command in 1 line before, but I had the same issue, and I just kept trying different solutions like separating the arguments and trying to escape it with different characters but it didn’t help.
what you suggested and was indeed helpful was using the shell and the 1 string line both together, and then escaping the double quotes with backslashes as follows:
${output} Run Process netstat -ano | find \"LISTENING\" | find \"${DEFAULT_PORT}\" shell=true