OpenQNX :: The QNX Community Portal

Jul 05, 2008 - 12:06 AM
Google
  Web openqnx.com   
     Create an account Home · Submit News · QNX Forums · QNX Download · Search   
_
Main Menu
Who's Online
There are 67 unlogged users and 0 registered users online.

You can log-in or register for a user account here.

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
Kevin Miller
Post subject: "Here document" in shell subroutine fails  PostPosted: Aug 20, 2004 - 09:12 PM
Guest





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
 
   
Reply with quote Back to top
bilcar
Post subject: Re: "Here document" in shell subroutine fails  PostPosted: Aug 20, 2004 - 09:12 PM
Senior Member


Joined: Feb 04, 2004
Posts: 573
Location: Crete, IL
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.
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
Steve Reid
Post subject: Re: "Here document" in shell subroutine fails  PostPosted: Aug 30, 2004 - 03:37 PM
Guest





Bill Caroselli <qtps@earthlink.net> wrote:
Quote:
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
------------------------------------------
 
   
Reply with quote Back to top
Kevin Miller
Post subject: Re: "Here document" in shell subroutine fails  PostPosted: Aug 30, 2004 - 04:00 PM
Guest





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...
Quote:
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.
 
   
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2007 The PNphpBB Group
Credits
All logos and trademarks in this site are property of their respective owners. The comments are property of their posters.
Powered by OpenQNX: The QNX Community Portal Site
QNX and the QNX logo are registered trademarks of QNX Software Systems.