0

I'm having trouble writing a simple script that pings its current network. I want the output to look the same as a normal ping but I'm having trouble getting to that point

here's the original question from the assignment

-write a short script(using the ping command)to do a "ping" scan of your current network.

any help you can give is much appreciated

I originally tried printf but I wasn't able to even get a decent output so I gave up and started using echo

This is what I have right now

#!/bin/bash

for ping in $(ping -c 4 -v 192.168.1.10)
  do echo $ping
done

my teacher said that I would run into two problems with the simple ping script and that I could find the answer in the ping man pages. however I can't seem to find anything to help.

I basically want the script to run as if I just ran a normal ping command and have it display output in the same way.

ceving
  • 21,900
  • 13
  • 104
  • 178
Emperor77
  • 21
  • 2

2 Answers2

0

According to the question from your assignment, I would say what you need to do is invoking ping in all the IP's in your current network (192.168.1.0 in case it is a /24 mask).

What you are trying to do is a simple ping to 192.168.1.10.

If that is the case, why don't you just call ping command in your script?

    #!/bin/bash

    ping -c 4 -v 192.168.1.10

I think what your teacher really wants is you to find the way of making a loop over all the IP directions in your network.

de12wey
  • 77
  • 1
  • 2
  • 11
-2
#!/bin/bash

ping= ping -c 4 -v 192.168.1.10
print $ping 

simply get the out put

Debugger
  • 494
  • 5
  • 18