-
Notifications
You must be signed in to change notification settings - Fork 10
Description
Many versions of netcat do not have the nc -G <integer> option. On many Linux OS's these will fail as a result.
One alternative is to use the -w option, and this won't have the same functionality so probably isn't a good choice.
Another alternative would be to use timeout from the GNU coreutils, if it is installed. This would help, and would also still leave a lot of POSIX operating systems unsupported.
It can be done by launching an interactive shell, as described here: https://unix.stackexchange.com/questions/10698/timing-out-in-a-shell-script/18711#18711
Perhaps the "right" thing to do is to look for nc in the path, verify it has the -G option, and use it. If it's not there or doesn't support -G, look for timeout and verify it's the GNU program (it's a commonly used name!) and use it if it is.
If that doesn't work, maybe we could try the interactive shell approach… and if that doesn't work, try to use perl or python, etc.
At the very least, though, we need an alternative to nc -G since it's common for nc to not support the -G option.