0

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

Andrew Thompson
169k42 gold badges224 silver badges441 bronze badges
asked Mar 22, 2012 at 16:54

1 Answer 1

3

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");
answered Mar 22, 2012 at 16:58
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you very much, that solved it. Any ideas why it's not an issue on windows?
Basically, if your previous version worked on windows, your lucky. But ProcessBuilder is only intended to work if you specify each parameter separately. The docs are unfortunately not specific about this.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.