2

This is seriously lame I know but...Im pulling my hair out on it.

Basically I Have this code:

getDisplayName(){
echo Display Name: $(/opt/vc/bin/tvservice  -n)
}

It returns this:

[E] No device present
Display Name:

I would expect it to be:

Display Name: [E] No Device Present

What am I missing?

TIA Ron

1
  • 1
    The error message is being sent to standard error, not standard output. Commented Apr 7, 2020 at 18:57

1 Answer 1

2

Looks pretty much like the error message from /opt/vc/bin/tvservice goes to the standard error stream (not standard output), so it is not captured by $(). Try redirecting to standard output using 2&>1 2>&1

getDisplayName(){
  echo Display Name: $(/opt/vc/bin/tvservice  -n 2>&1)
}
Sign up to request clarification or add additional context in comments.

2 Comments

This creates a file with name 1. I suggest to use 2>&1.
@Cyrus Yes, absolutely, thank you. Fxied the awnser.

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.