Results 1 to 3 of 3

Thread: is the syntax correct here:

  1. #1
    Join Date
    Feb 2012
    Beans
    81

    is the syntax correct here:

    #!/bin/bash
    ping -c 2 192.168.0.2 >/dev/null
    if [ $? -eq 1 ] ; then
    /usr/bin/wakeonlan 00:1d:92:dd:1a:0d
    sleep 5
    if [ "$(pidof xbmc.bin)" ] ; then
    killall -9 xbmc.bin
    sleep 60
    fi
    fi

    so if ping responds do nothing, if not the wake the remote computer, check for xbmc.bin locally, if xbmc.bin found kill it.

    I want the sleep 60 to only run if xbmc.bin is not found.
    Last edited by bilboubu; August 22nd, 2012 at 07:09 PM.

  2. #2
    Join Date
    Feb 2012
    Beans
    81

    Re: is the syntax correct here:

    tried

    #!/bin/bash
    ping -c 2 192.168.0.2 >/dev/null
    if [ $? -eq 1 ] ; then
    /usr/bin/wakeonlan 00:1d:92d:1a:0d
    sleep 5
    if [ "$(pidof xbmc.bin)" ] ; then
    killall -9 xbmc.bin
    else
    sleep 60
    fi
    fi


    but seems to have failed
    Last edited by bilboubu; August 22nd, 2012 at 10:28 PM.

  3. #3
    Join Date
    Oct 2009
    Location
    Elgin, IL USA
    Beans
    3,363
    Distro
    Ubuntu 16.10 Yakkety Yak

    Re: is the syntax correct here:

    "failed" is ambiguous. Did you get an error? Did it not wake the other computer? Who was xbmc.bin running as, and are you that user or have permission to kill a process of that user?

    It can help to liberally sprinkle a script with echo statements while developing it, so you can tell what path it followed, or if the result of part of it was different than you expected. Or add additional tests to see if the wakeonlan was successful and xmbc.bin was actually killed.

    When posting a script, it also helps to wrap it in code tags (highlight it and click # in message window) in case missing spaces or formatting matters.
    Last edited by efflandt; August 23rd, 2012 at 12:02 AM.
    i5 650 3.2 GHz upgraded to i7 870, 16 GB 1333 RAM, nvidia GTX 1060, 32" 1080p & assorted older computers

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
  •