Sip show peers CLI filters?

Hi all,
I’m trying to pull a list of my online peers from the CLI
The command “sip show peers” gives me the FULL list.
My question is, how can I filter it to:

  1. online (status = OK) only
  2. get the Name only

Example:
original output

VOIP*CLI> sip show peers
Name/username Host Dyn Forcerport Comedia ACL Port Status Description
2012/2012 xxx.xxx.xxx.xxx D No No A 5062 OK (102 ms)
2015/2015 xxx.xxx.xxx.xxx D No No A 5062 OK (93 ms)
2026/2026 xxx.xxx.xxx.xxx D No No A 5062 OK (97 ms)
2028/2028 xxx.xxx.xxx.xxx D No No A 5062 OK (98 ms)
2035/2035 xxx.xxx.xxx.xxx D No No A 5160 OK (10 ms)
2036/2036 (Unspecified) D Yes Yes A 0 UNKNOWN
3000/3000 xxx.xxx.xxx.xxx D No No A 5160 OK (9 ms)
3100 (Unspecified) D No No A 0 UNKNOWN
3101 (Unspecified) D No No A 0 UNKNOWN
4001/4001 xxx.xxx.xxx.xxx D No No A 5062 OK (102 ms)
4002/4002 xxx.xxx.xxx.xxx D No No A 5062 OK (100 ms)
4003/4003 (Unspecified) D No No A 0 UNKNOWN
4098/4098 xxx.xxx.xxx.xxx D No No A 5160 OK (10 ms)
4099/4099 xxx.xxx.xxx.xxx D No No A 5062 OK (98 ms)
4100/4100 xxx.xxx.xxx.xxx D No No A 5062 OK (101 ms)
4101/4101 xxx.xxx.xxx.xxx D No No A 5062 OK (103 ms)
4102/4102 xxx.xxx.xxx.xxx D No No A 5062 OK (103 ms)
4103/4103 xxx.xxx.xxx.xxx D No No A 5062 OK (104 ms)
4104/4104 xxx.xxx.xxx.xxx D No No A 5062 OK (103 ms)
4105/4105 xxx.xxx.xxx.xxx D No No A 5062 OK (98 ms)
4106/4106 xxx.xxx.xxx.xxx D No No A 5062 OK (104 ms)

The list that I need to be outputed is:

2012
2015
2026
2028
2035
3000
4001
4002
4098
4099
4100
4101
4102
4103
4104
4105
4106

Is there a way to do this?
Thanks

Hi,

Use shell

$ asterisk -rx ‘sip show peers’ | awk -F’/’ ‘{print $1}’

asterisk -x " sip show peers" | grep -w OK | awk ‘{print $1}’ | awk -F’/’ ‘{print $1}’

Thanks for the reply
I know this command, but I need a way to do this from the CLI (I’m connected to the CLI using AsterNET)

When you say CLI, We assume you are using asterisk -x command, but it seems you are using a .NET framework for Asterisk AMI and FastAGI. So in this case you will need to use the action SIPpeerstatus and apply some kind of.Net text filtering

When I say CLI, I mean

VOIP*CLI>

And yes, I’m using a .NET framework (that I don’t really understand… but I’m working hard to understand it)
I added a SHH.NET framework, I’ll try to do the command there…
I’ll update if/when I’m successful
Thanks

SSH.NET worked perfectly (well almost)
When I

cmd = sshClient.RunCommand(“asterisk -x ‘sip show peers’ | grep -w OK | awk ‘{print $1}’ | awk -F’/’ ‘{print $1}’”)
TextBox1.Text = cmd.Result

I get them all in the same line

If ext.Length > 4 Then ext = ext.Insert(4, Environment.NewLine)

does nothing
How do I add the new line?

The issue described above is related to your external app nothing related with Asterisk, and as I’m a PHP developer , I cant help you with .NET stuff or any other programming language

Ya, a second after I replied, I noticed that the last part was not related to Asterisk…
Thanks for your help so far, I posted my question in a different forum as well…