curl / Mailing Lists / curl-users / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: Use curl to check the status/availability of local/remote port(s).

From: Daniel Stenberg via curl-users <curl-users_at_cool.haxx.se>
Date: Mon, 11 Jan 2021 22:25:01 +0100 (CET)

On Mon, 11 Jan 2021, Hongyi Zhao via curl-users wrote:

> Say, for checking the availability of telnet server, I can use nc as
> follows:
>
> $ nc -z hostIP 23
>
> But I want to know if I can do the same job with curl too.

You *can* but it won't be as convenient:

Is there a SSH port listening?

$ curl --http0.9 --connect-timeout 3 localhost:22 -s -o /dev/null
$ echo $?
56

Yes!

Is there a TELNET port listening?

$ curl --http0.9 --connect-timeout 3 localhost:23 -s -o /dev/null
$ echo $?
7

Nope.

-- 
  / daniel.haxx.se
  | Commercial curl support up to 24x7 is available!
  | Private help, bug fixes, support, ports, new features
  | https://www.wolfssl.com/contact/
-----------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2021-01-11