PDA

View Full Version : ping: Name or service not known



Deeperthanrob
2019-12-06, 11:59
Hi all,

I'm writing a ping sweep script as part of some online training/labs and for some reason, each time I run it I get the error:

ping: 192.168.1.seq: Name or service not known

The script is:



#!/bin/bash
for ip in 'seq 1 254'; do
ping -c 1 $1.$ip | grep "64 bytes" | cut -d " " -f 4 | tr -d ":" &
done


As I am sure you can see; all it does is ping an inputted address range from 1 - 254 (and removes a few characters and spaces from the results)

e.g:

./ipsweep.sh 192.168.1

I'm pretty sure the script is fine as it works on other Kali deployments, just not mine!

I've trawled hours of search engine results and still cannot get this working, so reaching out to the experts! - Help! :)

Thanks in advance.

Rob.

Rasalom
2019-12-09, 08:36
EDIT

I gave away too much.

I'll say this, ' != `

JungleJim45
2020-01-30, 18:29
Try:
for ip in $(seq 1 254); do

If it still doesn't work, look at your sources.list file

Then do apt-get upgrade && apt-get update

rollercoaster
2020-01-31, 22:45
That is because your command substitution is incorrect, ie you're using apostrophe instead of backtick. You can try JungleJim45's suggestion or

`seq 1 254`

instead

Mister_X
2020-02-02, 00:33
It was because you use single quotes. It should be backticks, `, or as JumgleJim45 mentions, enclosed in $()