Operating System - HP-UX
1755420 Members
3010 Online
108832 Solutions
New Discussion юеВ

Script help me(about EOF)

 
Kyuyong-Kwon
Advisor

Script help me(about EOF)

Dear all
I have a question for script.
my shell is csh and os is hp-ux 11.23
i have a sript file as like:
#!/usr/bin/csh
CELLtalk -n YT5_MBX << 'EOF'
du *
'EOF'

how to run on to command-line?
For example)
$>CELLtalk -n YT5_MBX << 'EOF' \n du * \n 'EOF'
right my syntex?
But i could not get any results.

Please let me know...
have a good time.

9 REPLIES 9
Dennis Handly
Acclaimed Contributor

Re: Script help me(about EOF)

>my shell is csh

You should give up on the scummy C shell and switch to a real shell: ksh or sh

CELLtalk -n YT5_MBX << 'EOF'
du *
'EOF'

This looks like a here document. What are you intending to do with "du *"? Those single quotes don't look correct, try:
CELLtalk -n YT5_MBX <du *
EOF
Kyuyong-Kwon
Advisor

Re: Script help me(about EOF)

thank you for your fast reply.
Thats right.
I perceive that I have used single quotes.
Dose not run on to command line in Cshell?


Tor-Arne Nostdal
Trusted Contributor

Re: Script help me(about EOF)

Since you got the solution from Dennis perhaps you should assign him his points ;)
http://forums13.itrc.hp.com/service/forums/helptips.do?#33
I'm trying to become President of the state I'm in...
Dennis Handly
Acclaimed Contributor

Re: Script help me(about EOF)

>I perceive that I have used single quotes.

Do you know why you used quotes?

>Does not run on to command line in cshell?

No, you must have here documents on following lines.
Kyu-Yong Kwon
Frequent Advisor

Re: Script help me(about EOF)

Dear Dennis
>Do you know why you used quotes?
i've found it on the website.

>No, you must have here documents on following lines.

where is following lilnes?
Peter Nikitka
Honored Contributor

Re: Script help me(about EOF)

Hi,

even in csh the command in your script is not different to that in interactive mode:
nik@hpx6[200] csh
hpx6% cat >/tmp/xx <a
b
EOF
hpx6% cat /tmp/xx
a
b
hpx6%

The tcsh used a secondary prompt '?' as default:
cat >/tmp/xx <? a
? b
? EOF

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
James R. Ferguson
Acclaimed Contributor

Re: Script help me(about EOF)

Hi:

> >Dennis: No, you must have here documents on following lines.

where is following lilnes?

What is meant is that the body (lines) of the "here-document" must be written on lines that are separate from the '<<[-]word' line.

You could type these three lines:

# cat <<'EOF'
> today is $(date)
> EOF
today is $(date)
#

...As you know, when you type "EOF" and hit the keyboard ENTER or RETURN key, the string "today is..." is returned.

If you want command-substitution too, don't quote the here-document end-marker (the 'EOF') like this:

# cat <> today is $(date)
> EOF
today is Wed Dec 2 14:29:08 EST 2009
#

...Now, if you want to edit the document without retyping, recall it (esc+K) in a Korn or Posix shell and use the 'vi' editor to change it:

# cat <today is Wed Dec 2 14:29:38 EST 2009...a good day
#

The "^J" sequences represent newline sequences generated by pressing the return/enter key or by pressing the Control-key, a lowercase "v", and then a lowercase "j".

Regards!

...JRF...


Dennis Handly
Acclaimed Contributor

Re: Script help me(about EOF)

>I've found it on the website.

It appears it works similarly to a real shell except you don't quote the "word" at the end of the document.

>JRF: If you want command-substitution too, don't quote the here-document end-marker

It may be easier to use "\" to quote it.


Fredrik.eriksson
Valued Contributor

Re: Script help me(about EOF)

You can (atleast if you're using bash) do it like this:
command <<< "what the input should be"

For example:
CELLtalk -n YT5_MBX <<< "`du *`"

I'm not sure if this will work in CSH thou.

Best regards
Fredrik Eriksson