0

I'm trying to read the filtered output of the command into the array, but this results in an empty array. When I read the command into the array without the filter the array gets filled fine.

What am I missing here?

The regular output of the command:

gst-device-monitor-1.0 -f Source/Network:application/x-ndi
Probing devices...

Monitoring devices, waiting for devices to be removed or new devices to be added...

Device found:

        name  : PRO-CONVERT HDMI-NDI 001 (#00 (A405200518097))
        class : Source/Audio/Video/Network
        caps  : application/x-ndi
        properties:
                ndi-name = "PRO-CONVERT\ HDMI-NDI\ 001\ \(\#00\ \(A405200518097\)\)"
                url-address = 198.18.1.98:5961
        gst-launch-1.0 ndisrc ndi-name="PRO-CONVERT\ HDMI-NDI\ 001\ \(\#00\ \(A405200518097\)\)" url-address=198.18.1.98:5961 ! ...


Device found:

        name  : UBUNTU (2110_Transcoder_01)
        class : Source/Audio/Video/Network
        caps  : application/x-ndi
        properties:
                ndi-name = "UBUNTU\ \(2110_Transcoder_01\)"
                url-address = 198.18.1.94:5961
        gst-launch-1.0 ndisrc ndi-name="UBUNTU\ \(2110_Transcoder_01\)" url-address=198.18.1.94:5961 ! ...


Device found:

        name  : PRO-CONVERT HDMI-NDI 002 (#00 (A405200518100))
        class : Source/Audio/Video/Network
        caps  : application/x-ndi
        properties:
                ndi-name = "PRO-CONVERT\ HDMI-NDI\ 002\ \(\#00\ \(A405200518100\)\)"
                url-address = 198.18.1.53:5961
        gst-launch-1.0 ndisrc ndi-name="PRO-CONVERT\ HDMI-NDI\ 002\ \(\#00\ \(A405200518100\)\)" url-address=198.18.1.53:5961 ! ...

When I execute the command using the filter:

gst-device-monitor-1.0 -f Source/Network:application/x-ndi | awk '/name  :/ {$1=$2=""; print$0}'

It results in the filtered output:

  PRO-CONVERT HDMI-NDI 001 (#00 (A405200518097))
  PRO-CONVERT HDMI-NDI 002 (#00 (A405200518100))
  UBUNTU (2110_Transcoder_01)

But trying to read it into an array with filter applied:

readarray -t sources < <(gst-device-monitor-1.0 -f Source/Network:application/x-ndi | awk '/name  :/ {$1=$2=""; print$0}')

And then reading the array using:

declare -p sources

or

echo ${sources[@]}

Results in nothing. Reading the array using the command without the filter applied gives the array of all values. So everything seems to work, except when the filter is applied?

5
  • Related question? stackoverflow.com/questions/26634978 Commented Jan 15, 2024 at 17:12
  • I don't have the gst-device-monitor-1.0 program, but I copied your output to a file and used cat gstoutput.txt instead. It worked fine. Commented Jan 15, 2024 at 17:29
  • Can you reproduce it with readarray -t sources < <(cat gstoutput.txt | awk '/name :/ {$1=$2=""; print$0}')? Commented Jan 15, 2024 at 17:30
  • '''readarray -t sources < <(cat gstoutput.txt | awk '/name :/ {$1=$2=""; print$0}')''' works fine indeed '''(gst-device-monitor-1.0 -f Source/Network:application/x-ndi | awk '/name :/ {$1=$2=""; print$0}') > sources.txt''' however creates an empty file Not using the filter like '''gst-device-monitor-1.0 -f Source/Network:application/x-ndi > gstoutput.txt''' works fine again. Commented Jan 15, 2024 at 17:46
  • At least I have a workaround now first reading the output to a file or variable and then making the array Commented Jan 15, 2024 at 17:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.