Pipes (’ |
') in exec things do not seem to work (yet). Or should I do this in a different way?
If I am not mistaking, the pipe (|) is something that is parsed/interpreted internally by the shell (e.g bash), which is not the case when you execute literal commands. If you google on this subject will find some detailed explanation on why/how this is the case
What error does the piped-thing raise?
Did you tried to escape the pipe like: ping -c 1 8.8.8.8 | grep ‘packets transmitted’ ?
Also, try to remove the blank space between the pipe and grep: ping -c 1 8.8.8.8 |grep ‘packets transmitted’
Piped ping:
Thing exec:command:ping_google [command="ping -c 1 8.8.8.8 | grep 'packets transmitted'", interval=5, timeout=1, autorun=false]
produces
19:20:29.116 [INFO ] [marthome.event.ItemStateChangedEvent] - Test_Ping changed from PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: icmp_seq=0 ttl=45 time=14.975 ms
--- 8.8.8.8 ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 14.975/14.975/14.975/0.000 ms to usage: ping [-AaDdfnoQqRrv] [-c count] [-G sweepmaxsize]
[-g sweepminsize] [-h sweepincrsize] [-i wait]
[-l preload] [-M mask | time] [-m ttl] [-p pattern]
[-S src_addr] [-s packetsize] [-t timeout][-W waittime]
[-z tos] host
ping [-AaDdfLnoQqRrv] [-c count] [-I iface] [-i wait]
[-l preload] [-M mask | time] [-m ttl] [-p pattern] [-S src_addr]
[-s packetsize] [-T ttl] [-t timeout] [-W waittime]
[-z tos] mcast-group
Apple specific options (to be specified before mcast-group or host like all options)
-b boundif # bind the socket to the interface
-k traffic_class # set traffic class socket option
-K net_service_type # set traffic class socket options
-apple-connect # call connect(2) in the socket
-apple-time # display current time
usage: ping [-AaDdfnoQqRrv] [-c count] [-G sweepmaxsize]
[-g sweepminsize] [-h sweepincrsize] [-i wait]
[-l preload] [-M mask | time] [-m ttl] [-p pattern]
[-S src_addr] [-s packetsize] [-t timeout][-W waittime]
[-z tos] host
ping [-AaDdfLnoQqRrv] [-c count] [-I iface] [-i wait]
[-l preload] [-M mask | time] [-m ttl] [-p pattern] [-S src_addr]
[-s packetsize] [-T ttl] [-t timeout] [-W waittime]
[-z tos] mcast-group
Apple specific options (to be specified before mcast-group or host like all options)
-b boundif # bind the socket to the interface
-k traffic_class # set traffic class socket option
-K net_service_type # set traffic class socket options
-apple-connect # call connect(2) in the socket
-apple-time # display current time
Escaped pipe:
Thing exec:command:ping_google [command="ping -c 1 8.8.8.8 \| grep 'packets transmitted'", interval=5, timeout=1, autorun=false]
as last line in things file produces nothing.
I had another Thing definition, that was sort of included in the ping Thing.