3

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?

vihtor
  • 265
  • 2
  • 10

1 Answers1

2

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}"
Danny
  • 1,603
  • 1
  • 15
  • 25