If I try to do a “here document” in a shell subroutine, like this:
routine ()
{
cat <<-DONE
this is a test
of a here document
DONE
}
routine
I get an error message like this:
/tmp/sh1491500: cannot open (No such file or directory)
If I do the same in the main body of the shell script, for instance, by just
removing the “routine ()” from the above, it works just fine. Can anyone
shed some light on this?
Thanks,
Kevin
Kevin Miller <kevin.miller@transcore.com> wrote:
KM > If I try to do a “here document” in a shell subroutine, like this:
KM > routine ()
KM > {
KM > cat <<-DONE
KM > this is a test
KM > of a here document
KM > DONE
KM > }
KM > routine
KM > I get an error message like this:
KM > /tmp/sh1491500: cannot open (No such file or directory)
KM > If I do the same in the main body of the shell script, for instance, by just
KM > removing the “routine ()” from the above, it works just fine. Can anyone
KM > shed some light on this?
KM > Thanks,
KM > Kevin
I believe that the DONE must be on a line by itself with no white space
before or after it.
When this does work for you, was it still indented?
Try not indenting it.
Bill Caroselli <qtps@earthlink.net> wrote:
I believe that the DONE must be on a line by itself with no white space
before or after it.
I’ll mention this in the docs for ksh.
Steve Reid stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems
You know, I wondered where this question went. My apologies for
misposting…
“Bill Caroselli” <qtps@earthlink.net> wrote in message
news:cg5o7r$8i4$1@inn.qnx.com…
Kevin Miller <> kevin.miller@transcore.com> > wrote:
KM > If I try to do a “here document” in a shell subroutine, like this:
KM > routine ()
KM > {
KM > cat <<-DONE
KM > this is a test
KM > of a here document
KM > DONE
KM > }
KM > routine
KM > I get an error message like this:
KM > /tmp/sh1491500: cannot open (No such file or directory)
KM > If I do the same in the main body of the shell script, for instance,
by just
KM > removing the “routine ()” from the above, it works just fine. Can
anyone
KM > shed some light on this?
KM > Thanks,
KM > Kevin
I believe that the DONE must be on a line by itself with no white space
before or after it.
When this does work for you, was it still indented?
Try not indenting it.