How do I send a message using ping?

Ping command uses ICMP request as far as I know

So, is it possible to send a short text using the ping command directly from the command line?

+3


source to share


2 answers


How about ping -p pattern

? Please be aware that not all versions ping

support -p

.

You can specify up to 16 "pad" bytes to fill the packet you send. This is useful for diagnosing data-dependent problems in the network. For example -p ff will populate the sent packet with everyone.



eg. ping -p 486920686572652e www.example.com

where 486920686572652e = Hi here.

+7


source


#!/bin/python3
import sys, subprocess
text = sys.argv[1]
target = sys.argv[2]
if len(text)>16:
    print("Text too long!")
    exit()
enctext = r''.join( hex(ord(c)).split("x")[1] for c in text )
subprocess.check_output(["ping", "-p", enctext, "-c", "1", target])

      



Maybe this piece of code is helpful for someone

+2


source







All Articles