Re: Grabbing connection and link status with nmcli
- From: Colin Helliwell <colin helliwell ln-systems com>
- To: networkmanager-list gnome org, Thomas Haller <thaller redhat com>
- Subject: Re: Grabbing connection and link status with nmcli
- Date: Wed, 30 Aug 2017 18:00:00 +0100 (BST)
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
wrote:
I've not used nmcli in any of its more intricate ways, but are there
some
easily-parsed commands which will allow me to tell whether an
Ethernet
interface is up (a la 'nmcli conn up/down') AND the cable is
connected
('link/carrier state')?
I can grab some hints of the latter with /sys/class/net/eth0/carrier,
but
would prefer an approach that is harmonised through nmcli. Are there
a
couple of sub-commands that can be used rather than parsing the full
'nmcli
dev show' output? e.g. to output a couple of specific fields.
Hi,
how about:
LANG=C nmcli -t -m tabular -f WIRED-PROPERTIES.CARRIER device show "$DEV"
Thomas
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
integer/text.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]