[CentOS] HERE document in docker script file

H agents at meddatainc.com
Sat May 4 02:10:33 UTC 2019


On April 30, 2019 8:30:45 PM EDT, H <agents at meddatainc.com> wrote:
>On 04/30/2019 02:54 AM, Gianluca Cecchi wrote:
>> On Tue, Apr 30, 2019 at 4:44 AM H <agents at meddatainc.com> wrote:
>>
>>> I am trying to use a HERE document in a docker script file to
>generate a
>>> text file but must be doing something wrong since I get a warning
>message
>>> that I did not expect:
>>>
>>> EOF: line 6: warning: here-document at line 0 delimited by
>end-of-file
>>> (wanted `EOF')
>>>
>>> This is the sample script I am testing in my docker file:
>>>
>>> RUN bash -c "$(/bin/echo -e "cat << 'EOF' | tee -a /test.txt \
>>>     \n<test> \
>>>     \n  someting here \
>>>     \n  something else here \
>>>     \n</test>")" \
>>> EOF
>>>
>>> Can anyone see what is wrong in the above statement?
>>>
>>> Thanks.
>>>
>>>
>>>
>> The second EOF should be before  the part ")" \ and not after,
>because it
>> has to represent the closure of the first one above....
>>
>> So it should be something like this (I have put /tmp/test.txt as I
>tested
>> as non root user that cannot write into /)
>>
>> bash -c "$(/bin/echo -e "cat <<EOF | tee -a /tmp/test.txt \
>> \n<test> \
>> \n something here \
>> \n</test>
>> EOF
>> ")"
>>
>> I also removed the single apex from the first 'EOF'.
>>
>> I get:
>>
>> [g.cecchi at ope46 ~]$ ll /tmp/test.txt
>> ls: cannot access '/tmp/test.txt': No such file or directory
>>
>> [g.cecchi at ope46 ~]$ bash -c "$(/bin/echo -e "cat <<EOF | tee -a
>> /tmp/test.txt \
>>> \n<test> \
>>> \n something here \
>>> \n</test>
>>> EOF
>>> ")"
>> <test>
>>  something here
>> </test>
>>
>> [g.cecchi at ope46 ~]$ cat /tmp/test.txt
>> <test>
>>  something here
>> </test>
>> [g.cecchi at ope46 ~]$
>>
>>
>> HIH,
>> Gianluca
>> _______________________________________________
>> CentOS mailing list
>> CentOS at centos.org
>> https://lists.centos.org/mailman/listinfo/centos
>
>Thank you but in the docker script (running under Centos 7), I get
>error messages unless I add \ as below. However, the below script still
>results in an error message:
>
>RUN bash -c "$(/bin/echo -e "cat <<EOF | tee -a /tmp/test.txt \
>\n<test> \
>\n something here \
>\n</test> \
>EOF \
>")"
>
>bash: line 13: warning: here-document at line 0 delimited by
>end-of-file (wanted `EOF')
>
>It looks like I need to make some additional changes when it is used in
>a docker script?
>
>_______________________________________________
>CentOS mailing list
>CentOS at centos.org
>https://lists.centos.org/mailman/listinfo/centos

It seems that this warning message is a result of a restriction of it being used in a docker script.


More information about the CentOS mailing list