Author Topic: Ping Using the new launch.capture  (Read 3343 times)

0 Members and 1 Guest are viewing this topic.

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Ping Using the new launch.capture
« on: May 06, 2014, 05:22:38 PM »
Here is an improved version of Ping Using Launch.Capture (the original is after the line break)... it return 7 numbers:

Packets Send
Packets Received
Packets Lost

Minimum Time in ms
Maximum Time in ms
Average Time in ms

this can be used for network testing and descriptive voice feedback ...

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.0.0.3-->
<command id="385" name="Ping" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Launch.Capture</cmdType>
    <params>
      <param>C:\Windows\System32\ping.exe</param>
      <param>{1}</param>
      <param>True</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegExSingle</cmdType>
    <params>
      <param>Sent.*?(\d+).*Received.*?(\d+).*Lost.*?(\d+).*?(\d+).*Minimum.*?(\d+).*Maximum.*?(\d+).*Average.*?(\d+)</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.SetLastResult</cmdType>
    <params>
      <param>{Match.1.1}x{Match.1.2}x{Match.1.3}x{Match.1.4}x{Match.1.5}x{Match.1.6}x{Match.1.7}x</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <event>ping</event>
</command>

------------------------------------------------------------------------------

here is the xml for a ping command that uses the new Launch.Capture. its motor is windows ping.exe ... you can ping IP addresses or domain names (google.ca) that is passed as payload 1 ...

it will return either 1, 2, 3 or 4 depending on the number of successful replies .... I use that to check internet (ping google) and if I get less than 4 I ping yahoo before raising an event that the internet is not working


Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 1.9.3.2-->
<command id="374" name="Ping" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Launch.Capture</cmdType>
    <params>
      <param>C:\Windows\System32\ping.exe</param>
      <param>{1}</param>
      <param>True</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <params>
      <param>bytes=(.)* time(.)*ms </param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.SetLastResult</cmdType>
    <params>
      <param>{#M}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <event>ping</event>
</command>
« Last Edit: July 28, 2014, 11:33:01 PM by Haddood »
When Voice command gets tough, use hand gestures

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Ping Using the new launch.capture
« Reply #1 on: May 06, 2014, 05:31:12 PM »
Good idea, you can take also a look here http://voxcommando.com/forum/index.php?topic=1301.msg11240#msg11240
this works in the similar way, but with a piece of python code, which generate events in VC.
« Last Edit: May 06, 2014, 06:15:29 PM by jitterjames »
***********  get excited and make things  **********

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Ping Using the new launch.capture
« Reply #2 on: May 06, 2014, 06:18:25 PM »
Each method has its advantages.  Hadood's method is easier to set up for new users.  You can just paste the xml in your tree.

The advantage of the python method that I created is that it can monitor in the background, on its own thread, without interfering with the operation of speech recognition and other commands, and only raises an event when something changes.

If you want to actually ask the computer about an IP and then wait to find out the answer then Hadood's method is probably better.  If you want to monitor an IP address (or multiple addresses), then python is probably better.

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: Ping Using the new launch.capture
« Reply #3 on: May 06, 2014, 06:23:51 PM »
Kalle

that thread was my inspiration :). I was planning to output the ping into a text file to read it ... then James added the Launch Capture and made my life easier ...

I know we can pass payloads to python but it is not my forte for the moment, and in general I like to maximize my use of what windows offer.

this command is a foundation block to find which PCs are on in my network (I am looking for a command line IP scanner to built the IP table to xml payload, or a way to read the routing table from my linksys router) ...
 
  • scenario 1: I want to access my desktop I call VC on skype (or text it) to tell me if it is on (if RD failed) by pinging it, if fails send WOL wait a bit and ping again... etc.
  • scenario 2: Ping phones to see if family members are home (not very practical, as phones sleep and they can be forgotten)
« Last Edit: May 06, 2014, 06:34:42 PM by Haddood »
When Voice command gets tough, use hand gestures

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: Ping Using the new launch.capture
« Reply #4 on: July 28, 2014, 11:31:58 PM »
I updated the Ping command above to give it more informative feedback
When Voice command gets tough, use hand gestures

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Ping Using the new launch.capture
« Reply #5 on: July 29, 2014, 10:49:50 AM »
this command is a foundation block to find which PCs are on in my network (I am looking for a command line IP scanner to built the IP table to xml payload, or a way to read the routing table from my linksys router) ...

I think you can do a lot using the command line
Code: [Select]
arp -awhich should basically give you a list of all IPs that have been seen recently.  You will still need to follow up with a ping command to verify that they are actually still around because arp just gives you a look at the cache.

You can clear the arp cache now and then using
Code: [Select]
netsh interface ip delete arpcachebut it might not be a good idea to do this and anyway you'll still need to wait for the cache to be repopulated which can take a while and you won't know when it's ready.

So I would first use arp to get the full list, and then use regex to find all matches I am interested in such as IP addresses 192.168.0.1**
Code: [Select]
(192\.168\.0\.1\d\d) and then ping them all.

I don't know if it is possible that a device which is present on the network does not show up in the arp table at all though.  You'll have to try it and see. :)

This approach will take some time so it might be best to do it in python in its own thread, which could for example, update a map table, then in VC you could check the map table whenever you want.  Or something along those lines.

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: Ping Using the new launch.capture
« Reply #6 on: July 29, 2014, 06:00:37 PM »
I think you can do a lot using the command line
Code: [Select]
arp -awhich should basically give you a list of all IPs that have been seen recently.  You will still need to follow up with a ping command to verify that they are actually still around because arp just gives you a look at the cache.


James I do use arp -a to build payload of PCs for the WOL function ... it is a 2 step process first get MACs and the IP then reverse the IP to PC name and store it in the XML ... I am working on a VC LAN IP scanner :) just for the fun of it .. but I am encountering an issue with looping ...
When Voice command gets tough, use hand gestures