I was trying to work it on some occasions, but I think there is a slight problem.
Asterisk-RX "Core Show Call" | | Grep "active" | Cut-D '' -f1
Execute command, runs from / usr / sbin / asterisk
, launches it equally, makes executable executable Pipes out the output and, for the active call, grep generally receives an integer value, which I want to store in one variable and continue to make the script work from there.
I have been given a hard time for command.
I basically try to make that command in a shell script and store the value.
Can you point me towards the right direction?
about it:
active = $ (esteqik-rx "Core show call" | Ajax '$ 2 ==' active "{N = $ 1} END {printf ("% d ", n)} ')
To ensure this For awk uses printf
, if the active call line is left in your output, your variable is assigned 0
instead of blank.
Or alternatively, if you have a shell bit, you can use it to avoid all pipes:
read active _ _; If ["$ what" = "active"]; The breaker then & lt;
At the end of this loop, if no "active call" lines were observed, then $ active
is empty If you want, you can add:
active = $ {active: -0}
to specify a zero value If someone is not active call is reported.
(In my tests, 0 active call
reports with each run, so this blank handling is just insurance.)
No comments:
Post a Comment