getting p2p_device_address from wpa_cli status
Question: Is there any way to get different information from the command "wpa_cli
status", e.g., p2p_device_address, ssid etc. separately, ?

What i am currently using is by calling wpa_cli from a python script:

    
    
    import subprocess 
    cmd =  "wpa_cli -i wlan3 status"
    p = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
    stderr=subprocess.STDOUT, close_fds=True)
    output = p.stdout.read()
    

my output is printed out as:

    
    
    bssid=xx:xx:xx:xx:xx:xx
    ssid=lifa_2
    id=0
    mode=station
    pairwise_cipher=CCMP
    group_cipher=CCMP
    key_mgmt=WPA2-PSK
    wpa_state=COMPLETED
    ip_address=192.168.0.104
    p2p_device_address=xx:xx:xx:xx:xx:xx
    address=xx:xx:xx:xx:xx:xx
    uuid=xxxxx-xxxx-xxxx-xxxx-xxxxxxx
    

what i want here is the p2p_device_address only, i.e

    
    
    output = p.stdout.read() # in this case ouput must be a string containing only the address 
    

what i am thinking of my self is to use str.split() and select line 9, and do
some string manipulation to get the id, however that will be a hack, it will
be much smother to let wpa_cli to return the address only, if there any?


Answer: Try to use `pipe` in Linux:

    
    
    import subprocess 
    cmd =  "wpa_cli -i wlan3 status | grep ip_address"
    p = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
    stderr=subprocess.STDOUT, close_fds=True)
    output = p.stdout.read()
    

Then you will get the only line with `ip_address`.

