Results 1 to 4 of 4

Thread: Look if the computer answers

  1. #1
    Join Date
    Aug 2005
    Location
    Sweden
    Beans
    257
    Distro
    Xubuntu

    Look if the computer answers

    Hi
    I trying to make or find a bash script that run and see if a computer answers that is there then it do something or when is not there nothing happend.

    I have alot of script that is ready to use but them all is to advanced for the basic task I going to use.


    I just want to make it look if the computer is in the network it run a command and if not nothing happend.
    Cazz

  2. #2
    Join Date
    Apr 2012
    Beans
    6,966

    Re: Look if the computer answers

    maybe just a simple ping test?

    Code:
    $ ping -c1 192.168.1.102 >/dev/null 2>&1 && echo "Do something here"
    Do something here
    $
    $ ping -c1 192.168.1.103 >/dev/null 2>&1 && echo "Do something here"
    $

  3. #3
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,499
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Look if the computer answers

    Code:
    if ping -c 1 address > /dev/null
    then
      echo "it's alive"
    else
      echo "it's dead, Jim"
    fi
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  4. #4
    Join Date
    Aug 2005
    Location
    Sweden
    Beans
    257
    Distro
    Xubuntu

    Re: Look if the computer answers

    Thanks alot
    Cazz

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •