1847427 Members
3051 Online
110264 Solutions
New Discussion

scripting question

 
SOLVED
Go to solution
Asad Malik
Frequent Advisor

scripting question

I have these lines as part of a script:
svrmgrl >/dev/null <connect internal
shutdown immediate
exit
EOF
echo "shutdown Complete"

The last line does not execute. How EOF is being used. Oracle is being shutdown.
Thanks for help
7 REPLIES 7
Helen French
Honored Contributor

Re: scripting question

hey,

put echo "shutdown complete" before exit command. EOF stands for the End Of File

HTH,
Shiju
Life is a promise, fulfill it!
Sanjay_6
Honored Contributor

Re: scripting question

Hi Asad,

try this,

svrmgrl >/dev/null <connect internal
shutdown immediate
exit
echo "shutdown Complete"
EOF

Hope this helps.

Regds
Mark Greene_1
Honored Contributor

Re: scripting question

The EOF is the marker for the shell. The << tells the shell to use the following lines until the marker is reached as input for the command "srvmgrl", so the EOF marks where that input ends. It does not do anything nor will it display anything.

The other item you may want to check is that the output is being routed to /dev/null. You may want to send it to a file instead. Also, if this is being run from cron, any errors this process generates will be routed to e-mail, so you may want to consider logging standard error to a file as well.

--
mark
the future will be a lot like now, only later
A. Clay Stephenson
Acclaimed Contributor

Re: scripting question

Hi Asad:

Actually, it should work. The shell should process everything up to the 'EOF' as standard input for you svrmgrl command. The exit should thus refer to svrmgrl rather than an exit statement for the shell. This should have worked and your echo should have worked as expected. By the way, there is nothing special about 'EOF' you could have used 'end_of_commands', '!EOF!', or 'I_am_finished' as long as you specify it EXACTLY the same in both plasces. The most common mistake is to place whitespace before your markers in one place but not the other.
' EOF' is not the same as 'EOF'.

Regards, Clay
If it ain't broke, I can fix that.
Asad Malik
Frequent Advisor

Re: scripting question

HI
I used Sanjay's and Shiju's case and created this
echo start <echo one
echo two
echo three
EOF
echo go

I get output as
start
go

echo one
echo two
are not executed.

Clay
That is what i think that the final echo command should have worked. where is the mistake
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: scripting question

Hi again:

echo start <echo one
echo two
echo three
EOF
echo go

I would only expect you to see 'start' and 'go' in this case. Your 'here docs' is say use everything up to EOF as stdin for the command echo start. But since, echo ignores stdin only the ARGUMENT start is processed. The shell returns after the EOF and you execute the echo go. This is working just as you would expect. Again, there is nothing wrong with your svrmgrl script unless you are missing whitespace that does not post very well. Look for leading spaces or tabs - that will clobber you 'here docs' everytime.
If it ain't broke, I can fix that.
Asad Malik
Frequent Advisor

Re: scripting question

Hi
Clay, there was an additional tab at the end of EOF.
Issue is resolved now. Thanks for help Guys