I am able to successfully execute this on windows:
builder = new ProcessBuilder("cmd.exe", "/c", "nmap " + ipRange, "&cd");
But this on OSX fails:
builder = new ProcessBuilder("/usr/local/bin/nmap", ipRange);
With the error:
"Starting Nmap 5.51 ( http://nmap.org ) at 2012年03月22日 09:51 PDT
Invalid host expression: 127.0.0.1 -p T:80 -- colons only allowed in IPv6 addresses, and then you need the -6 switch
QUITTING!"
What is the correct way to create that ProcessBuilder for OSX? Thanks
1 Answer 1
I'm guessing you are trying to pass two separate parameters as one String in ipRange. The ProcessBuilder probably wraps the ipRange String with quotes and messes up the command syntax. You need to add all parameters separately
Not like this:
new ProcessBuilder("/usr/local/bin/nmap", "-foo foo -bar bar");
but like this:
new ProcessBuilder("/usr/local/bin/nmap", "-foo", "foo", "-bar", "bar");
2 Comments
Explore related questions
See similar questions with these tags.