ksh with input redirection in conjunction with pipes leads to syntax error `here-document not contained within command substitution`

Solution In Progress - Updated -

Issue

Following script

#!/bin/ksh
#
cat <<EOF | echo $(hostname)
qwerty
EOF

fails with message:

ksh: syntax error at line 3:  `'<<EOF' here-document not contained within command substitution`

Environment

  • Red Hat Enterprise Linux (RHEL) 6.4 and 6.5
  • ksh-20120801-10.el6
  • ksh-20100621-19.el6_4.4

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.