1846666 Members
4564 Online
110256 Solutions
New Discussion

Re: here-document <<EOF

 
SOLVED
Go to solution
Geetam
Frequent Advisor

here-document <<EOF

I am struggling with a script that uses a here-document.

This script works on HP-UX11 and Oracle 8.0.5

It does NOT work on HP-UX 10.20 and Oracle 7.3.4

--------------------------
script:
set -x
typeset x
x=`svrmgrl <&1
connect internal
alter system archive log current;
EOF`
echo $x

--------------
output (of set -x):
+ typeset x
+ + svrmgrl
+ 0< /tmp/sh14826.8 2>& 1



--------------
When I run it in a subshell, it looks like this:
+ typeset x
+ + svrmgrl
+ 0< /tmp/sh15224.7 2>& 1
Bus error(coredump)
$

--------------
When executing this script under other conditions, I have seen the Oracle errors:
MGR-11401: input error, unable to read input line
MGR-01508: unable to close the current file


============================================

# contents of /tmp (relevant part) after (the first version of) the event above
----------------------------------
-rw-r--r-- 1 oracle dba 408 Jul 24 15:40 sh14826.1
-rw-r--r-- 1 oracle dba 479 Jul 24 15:40 sh14826.2
-rw-r--r-- 1 oracle dba 273 Jul 24 15:40 sh14826.3
-rw-r--r-- 1 oracle dba 408 Jul 24 15:40 sh14826.4
-rw-r--r-- 1 oracle dba 273 Jul 24 15:40 sh14826.6
-rw-r--r-- 1 oracle dba 479 Jul 24 15:40 sh14826.5
-rw-r--r-- 1 oracle dba 51 Jul 24 15:40 sh14826.7

# the contents of the last file looks like that is the one that should have been used, but above it seems to try to use sh14826.8
---------------------------------------------
Gt $ more /tmp/sh14826.7
connect internal
alter system archive log current;

Can anybody give me some idea of what is going wrong?

Many thanks
6 REPLIES 6
RikTytgat
Honored Contributor

Re: here-document <<EOF

Hi,

This could well be a patchlevel problem.

What shell do you use? Do you have the same problem with sh and ksh?

There have been some problems with the HP-UX shells that could explain you behaviour, but I need more details.

If you are using the posix shell, following link might be interesting:

http://europe-support2.external.hp.com/cki/bin/doc.pl/sid=70d3ca160a8cb138bc/screen=ckiDisplayDocument?docId=200000048685504

Bye,
Rik

Bye,
Rik

Alan Riggs
Honored Contributor
Solution

Re: here-document <<EOF

It looks to me like you are running into problems wth the input stream redirection interfering with your remote session. I believe this is a side effect of your saving the output of the executed svrmgrl command in a variable (causing a temporary file to be sourced, rather than maintaining the here document). I have had no trouble with the simple form:

svrmgrl <connect internal
startup
EOF

I capture the output by having this script called by a wrapping script and redirecting stout and sterr to a logfile.
Kofi ARTHIABAH
Honored Contributor

Re: here-document <<EOF

Geetam, Alan is right - in addition if you want to check for the return status of the svrmgrl command, you can say:

svrmgrl <connect internal

EOF

x=$?
echo $x
nothing wrong with me that a few lines of code cannot fix!
Dragan Krnic
Frequent Advisor

Re: here-document <<EOF

echo "connect internalnalter system archive log current;" | svrmgrl

should work just fine. The here document is only meaningful if you really have a long text.
Dragan Krnic
Frequent Advisor

Re: here-document <<EOF

echo "connect internalnalter system archive log current;" | svrmgrl

should work just fine. The here document is only meaningful if you really have a long text.

in the above string "connect internal" should have been followed by 'backslash'-'n' instead of just 'n'.
Dragan Krnic
Frequent Advisor

Re: here-document <<EOF

echo "connect internal\nalter system archive log current;" | svrmgrl

should work just fine. The here document is only meaningful if you really have a long text.

(last try to make 'backslash' visible)