Script to check for presence of phone

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I'm running Blue Iris on a dedicated PC to monitor/record the cameras around my house.



I use https://github.com/magapp/blueiriscmd/blob/master/blueiris.py along with this script to monitor for the presence of mine and my wife's phones to trigger whether only the exterior cameras (home) or interior and exterior (away) cameras are activated.



loop=1
sleep=60

while [ "$loop" -eq "1" ]
do

echo ""
echo ""
echo ""
echo ""
echo Phone home = 0, Phone away = 1
#nmap -sn 192.168.1.130 | grep -q latency
arp-scan -r 10 192.168.1.0/24 | grep -q "XX:XX:XX:XX:XX:XX"
phone1=$?
echo OnePlus 5 = $phone1
#nmap -sn 192.168.1.132 | grep -q latency
arp-scan -r 10 192.168.1.0/24 | grep -q "XX:XX:XX:XX:XX:XX"
phone2=$?
echo Nexus 5 = $phone2
total=$(($phone1 + $phone2))
echo Phones Total command = $total

if [ "$total" -gt "1" ];
then
echo Detected 0 phones, Checking status of Blue Iris;
/usr/sbin/blueiris.py --host 192.168.1.1:29191 --user user --password password --list-profiles | grep "Profile 'Away' is active"
profile=$?
if [ "$profile" -eq "0" ];
then
echo Blue Iris profile is already Away;
else
echo Blue Iris profile is Home, setting profile to Away;
/usr/sbin/blueiris.py --host 192.168.1.1:29191 --user user --password password --set-profile Away;
fi
else
echo Detected 1 or more phones, Checking status of Blue Iris;
/usr/sbin/blueiris.py --host 192.168.1.1:29191 --user user --password password --list-profiles | grep "Profile 'Home' is active"
profile=$?
if [ "$profile" -eq "0" ];
then
echo Blue Iris profile is already Home;
else
echo Blue Iris profile is Away, setting profile to Home;
/usr/sbin/blueiris.py --host 192.168.1.1:29191 --user user --password password --set-profile Home
fi
fi
echo ""
echo ""
echo ""
echo ""
echo Execution done, sleeping for $sleep seconds
sleep $sleep
done


I've used both nmap and arp-scan to check for IP addresses and MAC addresses respectively, but I've found neither to be fully reliable and will occasionally not locate our phones on the network and activate the interior cameras when we are home. It will usually revert back after a cycle of the script.



What I'm looking for is some help in getting the check to run twice before changing the status of the cameras.



Thank you in advance.










share|improve this question

























    up vote
    0
    down vote

    favorite












    I'm running Blue Iris on a dedicated PC to monitor/record the cameras around my house.



    I use https://github.com/magapp/blueiriscmd/blob/master/blueiris.py along with this script to monitor for the presence of mine and my wife's phones to trigger whether only the exterior cameras (home) or interior and exterior (away) cameras are activated.



    loop=1
    sleep=60

    while [ "$loop" -eq "1" ]
    do

    echo ""
    echo ""
    echo ""
    echo ""
    echo Phone home = 0, Phone away = 1
    #nmap -sn 192.168.1.130 | grep -q latency
    arp-scan -r 10 192.168.1.0/24 | grep -q "XX:XX:XX:XX:XX:XX"
    phone1=$?
    echo OnePlus 5 = $phone1
    #nmap -sn 192.168.1.132 | grep -q latency
    arp-scan -r 10 192.168.1.0/24 | grep -q "XX:XX:XX:XX:XX:XX"
    phone2=$?
    echo Nexus 5 = $phone2
    total=$(($phone1 + $phone2))
    echo Phones Total command = $total

    if [ "$total" -gt "1" ];
    then
    echo Detected 0 phones, Checking status of Blue Iris;
    /usr/sbin/blueiris.py --host 192.168.1.1:29191 --user user --password password --list-profiles | grep "Profile 'Away' is active"
    profile=$?
    if [ "$profile" -eq "0" ];
    then
    echo Blue Iris profile is already Away;
    else
    echo Blue Iris profile is Home, setting profile to Away;
    /usr/sbin/blueiris.py --host 192.168.1.1:29191 --user user --password password --set-profile Away;
    fi
    else
    echo Detected 1 or more phones, Checking status of Blue Iris;
    /usr/sbin/blueiris.py --host 192.168.1.1:29191 --user user --password password --list-profiles | grep "Profile 'Home' is active"
    profile=$?
    if [ "$profile" -eq "0" ];
    then
    echo Blue Iris profile is already Home;
    else
    echo Blue Iris profile is Away, setting profile to Home;
    /usr/sbin/blueiris.py --host 192.168.1.1:29191 --user user --password password --set-profile Home
    fi
    fi
    echo ""
    echo ""
    echo ""
    echo ""
    echo Execution done, sleeping for $sleep seconds
    sleep $sleep
    done


    I've used both nmap and arp-scan to check for IP addresses and MAC addresses respectively, but I've found neither to be fully reliable and will occasionally not locate our phones on the network and activate the interior cameras when we are home. It will usually revert back after a cycle of the script.



    What I'm looking for is some help in getting the check to run twice before changing the status of the cameras.



    Thank you in advance.










    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I'm running Blue Iris on a dedicated PC to monitor/record the cameras around my house.



      I use https://github.com/magapp/blueiriscmd/blob/master/blueiris.py along with this script to monitor for the presence of mine and my wife's phones to trigger whether only the exterior cameras (home) or interior and exterior (away) cameras are activated.



      loop=1
      sleep=60

      while [ "$loop" -eq "1" ]
      do

      echo ""
      echo ""
      echo ""
      echo ""
      echo Phone home = 0, Phone away = 1
      #nmap -sn 192.168.1.130 | grep -q latency
      arp-scan -r 10 192.168.1.0/24 | grep -q "XX:XX:XX:XX:XX:XX"
      phone1=$?
      echo OnePlus 5 = $phone1
      #nmap -sn 192.168.1.132 | grep -q latency
      arp-scan -r 10 192.168.1.0/24 | grep -q "XX:XX:XX:XX:XX:XX"
      phone2=$?
      echo Nexus 5 = $phone2
      total=$(($phone1 + $phone2))
      echo Phones Total command = $total

      if [ "$total" -gt "1" ];
      then
      echo Detected 0 phones, Checking status of Blue Iris;
      /usr/sbin/blueiris.py --host 192.168.1.1:29191 --user user --password password --list-profiles | grep "Profile 'Away' is active"
      profile=$?
      if [ "$profile" -eq "0" ];
      then
      echo Blue Iris profile is already Away;
      else
      echo Blue Iris profile is Home, setting profile to Away;
      /usr/sbin/blueiris.py --host 192.168.1.1:29191 --user user --password password --set-profile Away;
      fi
      else
      echo Detected 1 or more phones, Checking status of Blue Iris;
      /usr/sbin/blueiris.py --host 192.168.1.1:29191 --user user --password password --list-profiles | grep "Profile 'Home' is active"
      profile=$?
      if [ "$profile" -eq "0" ];
      then
      echo Blue Iris profile is already Home;
      else
      echo Blue Iris profile is Away, setting profile to Home;
      /usr/sbin/blueiris.py --host 192.168.1.1:29191 --user user --password password --set-profile Home
      fi
      fi
      echo ""
      echo ""
      echo ""
      echo ""
      echo Execution done, sleeping for $sleep seconds
      sleep $sleep
      done


      I've used both nmap and arp-scan to check for IP addresses and MAC addresses respectively, but I've found neither to be fully reliable and will occasionally not locate our phones on the network and activate the interior cameras when we are home. It will usually revert back after a cycle of the script.



      What I'm looking for is some help in getting the check to run twice before changing the status of the cameras.



      Thank you in advance.










      share|improve this question













      I'm running Blue Iris on a dedicated PC to monitor/record the cameras around my house.



      I use https://github.com/magapp/blueiriscmd/blob/master/blueiris.py along with this script to monitor for the presence of mine and my wife's phones to trigger whether only the exterior cameras (home) or interior and exterior (away) cameras are activated.



      loop=1
      sleep=60

      while [ "$loop" -eq "1" ]
      do

      echo ""
      echo ""
      echo ""
      echo ""
      echo Phone home = 0, Phone away = 1
      #nmap -sn 192.168.1.130 | grep -q latency
      arp-scan -r 10 192.168.1.0/24 | grep -q "XX:XX:XX:XX:XX:XX"
      phone1=$?
      echo OnePlus 5 = $phone1
      #nmap -sn 192.168.1.132 | grep -q latency
      arp-scan -r 10 192.168.1.0/24 | grep -q "XX:XX:XX:XX:XX:XX"
      phone2=$?
      echo Nexus 5 = $phone2
      total=$(($phone1 + $phone2))
      echo Phones Total command = $total

      if [ "$total" -gt "1" ];
      then
      echo Detected 0 phones, Checking status of Blue Iris;
      /usr/sbin/blueiris.py --host 192.168.1.1:29191 --user user --password password --list-profiles | grep "Profile 'Away' is active"
      profile=$?
      if [ "$profile" -eq "0" ];
      then
      echo Blue Iris profile is already Away;
      else
      echo Blue Iris profile is Home, setting profile to Away;
      /usr/sbin/blueiris.py --host 192.168.1.1:29191 --user user --password password --set-profile Away;
      fi
      else
      echo Detected 1 or more phones, Checking status of Blue Iris;
      /usr/sbin/blueiris.py --host 192.168.1.1:29191 --user user --password password --list-profiles | grep "Profile 'Home' is active"
      profile=$?
      if [ "$profile" -eq "0" ];
      then
      echo Blue Iris profile is already Home;
      else
      echo Blue Iris profile is Away, setting profile to Home;
      /usr/sbin/blueiris.py --host 192.168.1.1:29191 --user user --password password --set-profile Home
      fi
      fi
      echo ""
      echo ""
      echo ""
      echo ""
      echo Execution done, sleeping for $sleep seconds
      sleep $sleep
      done


      I've used both nmap and arp-scan to check for IP addresses and MAC addresses respectively, but I've found neither to be fully reliable and will occasionally not locate our phones on the network and activate the interior cameras when we are home. It will usually revert back after a cycle of the script.



      What I'm looking for is some help in getting the check to run twice before changing the status of the cameras.



      Thank you in advance.







      shell-script






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Sep 26 '17 at 18:39









      moeava

      11




      11

























          active

          oldest

          votes











          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f394609%2fscript-to-check-for-presence-of-phone%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f394609%2fscript-to-check-for-presence-of-phone%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Bahrain

          Postfix configuration issue with fips on centos 7; mailgun relay