D
D
Dmitry2016-09-12 18:31:08
Java
Dmitry, 2016-09-12 18:31:08

Why command in bash from IntelliJ Idea (JAVA) is not executed?

Greetings. Working with command line on OS X El Capitan from Java. There are no problems in the code for sure, all sorts of ls, uptime, etc. performed excellently. But netcat or nc is not running. Specifically like this:

p = Runtime.getRuntime().exec("nc -z -v " + host + " " + port);

Moreover, it looks as if it worked and did not spit out anything in stdout.
Maybe something with permissions?
PS IntelliJ Idea under sudo launched.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Saboteur, 2016-09-12
@saboteur_kiev

PATH to nc and netcat is correct?
It often happens that /usr/bin or something else is missing.
The simplest check is to write the full path instead of exec("nc -z -v " + host + " " + port), for example exec("/bin/nc -z -v " + host + " " + port)
But on the other hand on the other hand, run nc host port manually - if nothing hangs there, it doesn't output anything, like:
$ nc localhost 8080
$

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question