Re: Output silence!


On Fri, 2021-04-16 at 17:52 -0700, Abu Rasheda via networkmanager-list
When a command is executed using nmcli, on the success a line like the
following is printed.

Connection 'eth0-ethernet' (a24480cb-f5d6-40a6-a716-dba09ab53d07)
successfully added.

Is it possible to not have this line go to standard out? 

without using ">" operator. May some switch can be passed to nmcli

No. Use shell and its redirection feature. There is nothing wrong with
using shell's features to redirect and process the output. What is the
problem with that?

In general, nmcli should be usable from scripts, while also pleasing ot
the interactive, human user. That is a conflict. If you write a script,
you would not want this extra text but only get the UUID (or a

I guess, nmcli should get better here, and providing alternative
outputs that are more consumable by scripts. But the result would be
only more command line options, that all become part of the stable
API... we are slow and reluctant to change (or even extend) the output
of nmcli.

For example, if you go full measure, you could be very strict about
parsing the output and do something like:

nmcli_my_add() {
    local x
    x=$(LANG=C nmcli connection add "$@") || return 1
    x="$(printf "%s" "$x" | sed -n 's/^Connection '.*' (\(.\+\)) successfully aadded\.$/\1/p')"
    test -n "$x" || return 1 # Something is wrong, we failed to parse the output!!
    printf "%s\n" "$x"

UUID="$(nmcli_my_add type ethernet ...)"


Attachment: signature.asc
Description: This is a digitally signed message part

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