Reputation: 265
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?
Upvotes: 3
Views: 1922
Reputation: 1703
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}"
Upvotes: 2