How I can catch output of gitlab-runner in bash

Viewed 1264

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

How I can catch this output?

1 Answers

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}"
Related