Re: Grabbing connection and link status with nmcli

On 30 August 2017 at 17:51 Thomas Haller <thaller redhat com> wrote:

On Wed, 2017-08-30 at 17:17 +0100, colin helliwell ln-systems com

I've not used nmcli in any of its more intricate ways, but are there
easily-parsed commands which will allow me to tell whether an
interface is up (a la 'nmcli conn up/down') AND the cable is
('link/carrier state')?
I can grab some hints of the latter with /sys/class/net/eth0/carrier,
would prefer an approach that is harmonised through nmcli. Are there
couple of sub-commands that can be used rather than parsing the full
dev show' output? e.g. to output a couple of specific fields.


how about:

LANG=C nmcli -t -m tabular -f WIRED-PROPERTIES.CARRIER device show "$DEV"


Thanks Thomas, that's the hints I was looking for :)
I see I can do similar with GENERAL.STATE, for whether the connection has been taken up/down, and then 
logically And the two. 
But is there a way to be assured of what the textual result will be for this one: 100/30/20, 
"connected"/"disconnected"/"unavailable" ? It could be a headache if NM changes one day and alters the 

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]