Re: ping script

2022-02-27 Thread 황병희
Dear Barry,

Barry Scott  writes:

>> [...]
> This is correct python3.org  is only setup for email.
> Use the host and dig commands to check for yourself.

It is very amazing! Thanks for explanation!

> Compare
>
> $ host python.org 
>
> with
>
> $ host python3.org
>
> And compare:
>
> $ dig -t A python.org 
> $ dig -t MX python.org 
>
> with
>
> $ dig -t A python3.org 
> $ dig -t MX python3.org 
>
> Barry
>

Sincerely, Linux fan Byung-Hee

-- 
^고맙습니다 _布德天下_ 감사합니다_^))//
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ping script

2022-02-27 Thread Barry Scott



> On 27 Feb 2022, at 13:53, Byung-Hee HWANG  wrote:
> 
> simple ping check script with python3 (Python 3.9.2)
> tested under Debian 11 Bullseye:
> 
> soyeomul@penguin:~/gitlab/test$ ./fping.py localhost
> ok
> soyeomul@penguin:~/gitlab/test$ ./fping.py python.org
> ok
> soyeomul@penguin:~/gitlab/test$ ./fping.py python3.org
> python3.org: No address associated with hostname
> something is wrong...

This is correct python3.org  is only setup for email.
Use the host and dig commands to check for yourself.

Compare

$ host python.org 

with

$ host python3.org

And compare:

$ dig -t A python.org 
$ dig -t MX python.org 

with

$ dig -t A python3.org 
$ dig -t MX python3.org 

Barry

> soyeomul@penguin:~/gitlab/test$ 
> 
> Signed-off-by: Byung-Hee HWANG 
> ---
> fping.py | 31 +++
> 1 file changed, 31 insertions(+)
> create mode 100755 fping.py
> 
> diff --git a/fping.py b/fping.py
> new file mode 100755
> index 000..ccc1e58
> --- /dev/null
> +++ b/fping.py
> @@ -0,0 +1,31 @@
> +#!/usr/bin/env python3
> +# -*- coding: utf-8 -*-
> +
> +from subprocess import PIPE, Popen
> +from os import path
> +import sys
> +
> +"""
> +REFERENCE:
> +
> +"""
> +
> +if not path.isfile('/usr/bin/fping'):
> +sys.exit("you first install fping, then try again...")
> +
> +def check(xyz):
> +cmd = "fping %s" % (xyz)
> +try_ = Popen(cmd, stdout=PIPE, shell=True)
> +output = try_.communicate()[0].decode("utf-8")
> +
> +return output
> +
> +
> +if __name__ == "__main__":
> +xyz = sys.argv[1]
> +if "alive" in check(xyz):
> +print("ok")
> +else:
> +print("something is wrong...")
> +
> +# 2022-02-27, GNU Emacs 27.1 (Debian 11 Bullseye)
> -- 
> 2.30.2
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


ping script

2022-02-27 Thread Byung-Hee HWANG
simple ping check script with python3 (Python 3.9.2)
tested under Debian 11 Bullseye:

soyeomul@penguin:~/gitlab/test$ ./fping.py localhost
ok
soyeomul@penguin:~/gitlab/test$ ./fping.py python.org
ok
soyeomul@penguin:~/gitlab/test$ ./fping.py python3.org
python3.org: No address associated with hostname
something is wrong...
soyeomul@penguin:~/gitlab/test$ 

Signed-off-by: Byung-Hee HWANG 
---
 fping.py | 31 +++
 1 file changed, 31 insertions(+)
 create mode 100755 fping.py

diff --git a/fping.py b/fping.py
new file mode 100755
index 000..ccc1e58
--- /dev/null
+++ b/fping.py
@@ -0,0 +1,31 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+from subprocess import PIPE, Popen
+from os import path
+import sys
+
+"""
+REFERENCE:
+
+"""
+
+if not path.isfile('/usr/bin/fping'):
+sys.exit("you first install fping, then try again...")
+
+def check(xyz):
+cmd = "fping %s" % (xyz)
+try_ = Popen(cmd, stdout=PIPE, shell=True)
+output = try_.communicate()[0].decode("utf-8")
+
+return output
+
+
+if __name__ == "__main__":
+xyz = sys.argv[1]
+if "alive" in check(xyz):
+print("ok")
+else:
+print("something is wrong...")
+
+# 2022-02-27, GNU Emacs 27.1 (Debian 11 Bullseye)
-- 
2.30.2

-- 
https://mail.python.org/mailman/listinfo/python-list