Script with telnet command


New member
I want to test if a server is online.
The shell script "echo quit | telnet $IP 22 >/dev/null; echo $?" is ok, but telnet is not found in macrodroid.
how Can i do that ?


New member
Hi dsnz
My service is NAT behing a router. Than IP address is normaly always on. Ping command can't return the real state of my service :(


New member
I tried to use netcat :
nc -w 5 ${IP} ${port} </dev/null >/dev/null; echo $?
but, same problem, it's the router who reply... and the redirection exist, even if no service behind is alive.

Another solution is to create/delete the redirection when service is online (internal network), but I don't found an API to manage it.


Active member
and what kind of service is your server providing ?

is it http ? (then use a http get action)
is it udp protocol ? (there is a udp send , though the reply back is another thing .....)
... etc.

you should tell more in order to check the service that the server provides

or alternatively

instead of checking the server (this is different than the service !!) as you want to do now by use of telnet which is a security danger (very big)


why not install a simple http server (there are a ton available, even can have a tiny one with python) and test it with a http get action


New member
I found a solution
For your answer : I want to know if my ssh service is online

The Script Shell in macrodroid :
nc -w 5 [lv=host] [lv=port] < /dev/null

if the service is online, the stdout give the version of SSH service : for me = SSH-2.0-OpenSSH_8.4
If the service is not reachable, no stdout