Added: 1 year ago
From: metalx1000
Views: 3,701
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (28)

Sign In or Sign Up now to post a comment!
  • done. first line:

    for i in $(netstat --route |grep default |awk '{print $2}' |cut -d\. -f1,2,3).{1..254}

  • Thanks a lot for this tutorial!

    I am thinking about making a script that combines this tutorial's information with somehow grabbing automatically the gateway of the router. For that I'll have to study more about variables, though.

  • @metalx1000 @XW0RKS

    "nslookup" shows host names.

    ##

    for i in 192.168.1.{1..254}; do nslookup $i; done | grep name

    ##

  • @Karmaklaert: I'll give that a try, but I didn't think that would work for computers on the local network.

  • what do you add to script so it can also display a host names of witch ips it founds ??? (i hope the question is put out the right way)

  • @XW0RKS: That is a good question. I've looked in the past and I have not been able to find a command that will find host names. Sorry. I'm sure it can be done, I just don't know how. When I need host names from my network I use Etherape, which is a GUI program, so it doesn't help us much here.

  • Comment removed

  • for some reason this is the output I get

    "root@bt:~# for i in 192.168.1.{1..254} ;do if ping -c1 -w1 $i &>/dev/null;then echo $i is up;else $i is down;fi;done

    bash: 192.168.1.1: command not found

    bash: 192.168.1.2: command not found

    bash: 192.168.1.3: command not found

    ^Z

    [7]+ Stopped  ping -c1 -w1 $i >&/dev/null

    "

  • @orochinagi1111: you for got the 'echo'

    you wrote:

    for i in 192.168.1.{1..254} ;do if ping -c1 -w1 $i &>/dev/null;then echo $i is up;else $i is down;fi;done

    you should have wrote:

    for i in 192.168.1.{1..254} ;do if ping -c1 -w1 $i &>/dev/null;then echo $i is up;else echo $i is down;fi;done

  • @metalx1000 thank you!!!!

  • could you please elaborate more on "ping -c1 -w1 $i &>/dev/null"

    More specifically on -c1 and -w1 what are those?

    I am guessing you are inputting in a place '/dev/null' with '>' symbol? what is '&' for?

  • @Cryptoxicon: sure,

    -c1 means ping only once.

    -w1 means only wait 1 second for a reply

    & means to not wait for this command to finish before running the next command (Basically it will speed things up. It will start ping all the ip's without waiting for a response for each one. )

    >/dev/null just prevents the output of 'ping' from displaying on the screen.

  • @metalx1000 Thanks for your response. I also got your "Secure FTP with sftp and ssh" link. Very helpful. I tried ssh from my laptop (ubuntu 10.10) to my PC (ubuntu 10.10 partition) with no problem. I wanted to test it on a different OS. From my ubuntu laptop to my PC (windows 7 partition) I couldn't connect. Is it at all possible?

  • @Cryptoxicon: ssh is available on most OSes (Linux, Mac, BSD, etc...) But once again Windows Fails at being useful out of the box. I know you can use Putty as a ssh client on Windows, but I've never setup a ssh server on Windows. I know it's possible, but I think it talks a number of steps. If you just need file transfer, ftp would be a good option or SAMBA which allows you to access shared folders on a Windwos Machine.

  • @metalx1000 Thanks, I'll research some more on that.

  • @metalx1000 I've heard, OPENSSH is good on windows,

  • Is there a way to find out the hostnames?

  • @russjr08: Good Question. I'm sure there is a command for it. But I don't know what it is. Etherape will show you the hostname of computers. I'll look around and see if I can find an answer

  • @metalx1000 Thanks!

  • Interesting. Did you find out why you couldn't kill the process?

  • @Tarnus88: My guess it that when I tried to ctrl+c it was kill that instance in the loop. So, if it still had 225 computers to ping I would have had to ctrl+c 225 more times. That's just a guess, but I would bet that's it.

  • @metalx1000 Hm, is there a way to get around that? Somehow build in something that checks if a certain button(q for example) was pressed and exits the loop after that?

  • @Tarnus88: could probably through the loop into the background with a '&' and then set you script to wait for user input. And on certain input kill the script. I'll play with it some tomorrow.

  • Cool vid :)

Loading...
Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more