How I can catch output of gitlab-runner in bash
How I can catch output of gitlab-runner in bash
Why when I write into terminal
#!/bin/bash
out=`gitlab-runner list`
echo "list: $out"
out
variable is still empty and output of the command always display in terminal? Install Gitlab Runner
out
How I can catch this output?
list:
Command output first. Then
list:
– vihtor
Sep 14 '18 at 7:05
list:
1 Answer
1
gitlab-runner list outputs the list on stderr, thus you would not catch it as output to stdout.
see Bash how do you capture stderr to a variable?
and change your script to:
#!/bin/bash
out="$(gitlab-runner list 2>&1)"
echo "list: $out"
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy
What's the output you're getting? A list and then a line with
list:
afterwards?– that other guy
Sep 14 '18 at 4:26