Только для полноты, Bash был бы чем-то вроде этого:
$ netcat $HOST $PORT -w 1 -q 0 </dev/null && do_something
-w 1
указывает, что тайм-аут 1 секунды, и -q 0
говорит, что при соединении закрывают соединение, как только stdin
дает EOF
(который /dev/null
немедленно сделает).
Bash также имеет свои собственные встроенные сервисы TCP/UDP, но они - опция времени компиляции, и мне не скомпилировали Bash с ними :P
Put the name (preferably with an absolute path) and the arguments in a list and call execute()
:
['/path/to/script', 'arg1', 'arg2'].execute()
The Groovy documentation suggests to use a simple string instead. I advise against that because it can cause all kinds of problems with special characters, white space in arguments, etc.