Operating System - HP-UX
1849844 Members
2054 Online
104044 Solutions
New Discussion

Re: what does "-eeof $*" mean ?

 
someone_4
Honored Contributor

what does "-eeof $*" mean ?

Hi,

I am working with some cnr dhcp scripts. And we are writting scripts to access the nrcmd though a command line.I am trying to understand how this scripting works.
The follwing is a script called cnrque.

nrcmd -C localhost -N username -P password -r<<-eeof
$*
eeof

I undersand most of it that we are accessing the nrcmd though the localhost with the username after the -N and the password after the -P with read only access.

But I dont dont really understand what the last part means.

<<-eeof
$*
eeof

It is some kind of redirection from the command line because
./cnrque dhcp gethealth
gets me the health of the dhcp server.

So I understand that the eeof is feeding the dhcp gethealth though the script.
I just want more information about it what is it actully doing and what do the $* mean. And mabe some other scripting examples of this.

thanks

~ Richard
5 REPLIES 5
Jordan Bean
Honored Contributor

Re: what does "-eeof $*" mean ?



This is a "here-document" where the command line parameters are being expanded before they are fed into the program via standard input. The - ahead of eeof allows for indenting to be ignored.

Jordan Bean
Honored Contributor

Re: what does "-eeof $*" mean ?


Actually, that sounds a bit vague. Do this:

man sh-posix

and search ahead for here-doc

Tom Danzig
Honored Contributor

Re: what does "-eeof $*" mean ?

The command (i.e. connamd line arguments in this case) are apsswd to the invoked program.

Note that the - does allow indenting WITH TABS ONLY; not spaces.
Tom Danzig
Honored Contributor

Re: what does "-eeof $*" mean ?

Was my previous post that the worst case of typing you ever saw!

Should read:

The command (i.e. command line arguments in this case) are applied to the invoked program.

Note that the "-" does allow indenting WITH TABS ONLY; not spaces.


Sorry :(
Tom Maloy
Respected Contributor

Re: what does "-eeof $*" mean ?

It's a "here document", which is a shell construct. Used to make stuff purty, or instead of a bunch of print or echo statements. For example,

cat <<- EOF #deletes leading TABs, quits at EOF
Dear $name,

I am writing this on $(date).
blah blah

EOF

If you use << instead of <<-, then leading TABs will be preserved. That would allow you to keep any indents you applied to the text.

Note that EOF (or whatever pattern you pick) needs to start at the start of the line, and be alone on the line. So using

asdf EOF adf

will NOT stop the cat. You need EOF alone:

EOF

Tom
Carpe diem!