0

I want to assign a variable after executing the set of commands The first command is to get into the shell of the openshift pod. Then cat a file and assign that to a variable outside the openshift container.

I tried it like this

check=$(oc rsh pod << EOF
cat /var/lib/jenkins/.ssh/check.pub
EOF)

It gives me an error

bash: warning: here-document at line 41 delimited by end-of-file (wanted `EOF')
Benjamin W.
  • 46,058
  • 19
  • 106
  • 116

1 Answers1

2

I believe the second EOF needs to be on a line by itself:

check=$(oc rsh pod << EOF 
cat /var/lib/jenkins/.ssh/check.pub 
EOF
)
Dale C. Anderson
  • 2,280
  • 1
  • 24
  • 24
  • Indeed, and, generally, _no_ trailing characters, not even tabs or spaces, are allowed. In this special case - end-of-file with respect to the _command substitution_ (`$(...)`) - the delimiter is still _recognized_ (i.e., the code works), but a _warning_ is issued. Note that the warning was introduced in Bash v4; Bash 3.x quietly accepts the code in the question. – mklement0 May 17 '17 at 17:22