Skip navigation.
Home
The QNX Community Portal

View topic - "Here document" in shell subroutine fails

"Here document" in shell subroutine fails

Read-only archive of qnx.3rdparty_product_announcements (general 3rd Party product announcements) at inn.qnx.com

"Here document" in shell subroutine fails

Postby Kevin Miller » Fri Aug 20, 2004 9:12 pm

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
 

Re: "Here document" in shell subroutine fails

Postby bilcar » Fri Aug 20, 2004 9:12 pm

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.
bilcar
Senior Member
 
Posts: 573
Joined: Wed Feb 04, 2004 5:50 pm
Location: Crete, IL

Re: "Here document" in shell subroutine fails

Postby Steve Reid » Mon Aug 30, 2004 3:37 pm

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
------------------------------------------
Steve Reid
 

Re: "Here document" in shell subroutine fails

Postby Kevin Miller » Mon Aug 30, 2004 4:00 pm

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.
Kevin Miller
 


Return to qnx.3rdparty_product_announce

Who is online

Users browsing this forum: No registered users and 1 guest

cron