Can you tell me why the last command(echo) in this script does not execute?
In the command line I have to hit control -d to terminate this tag but I dont know how to do it in a shell script.
sqlplus -s <<EOF
connect / as sysdba
select sysdate from dual;
quit;
EOF
echo "other things to do"
I don't understand your question, but maybe a bunch of examples can help.
vnix$ cat <<HERE | wc
two words
make that five
HERE
2 5 25
vnix$ nl <<HERE | sed 's/no//' >/tmp/ovtpvt
foo no line numbers
HERE
vnix$ cat /tmp/ovtpvt
1 foo line numbers
vnix$ cat <<HERE >/tmp/song.txt
I'm a ${work} and I'm $adjective
HERE
vnix cat /tmp/song.txt
I'm a Lumberjack and I'm okay
... the last example of course assuming you have set the environment variables $work and $adjective correctly. (-:
How can I make this variable substitution inside EOF?
$newv and ${newv} are interpreted literally
for i in `cat textfile`
do
newv="ALTER SYSTEM KILL SESSION '$i' IMMEDIATE;"
sqlplus -s <<'EOF'
connect / as sysdba
$newv
quit
EOF
done
output is:
SP2-0042: unknown command "$newv" - rest of line ignored.
You can mix and match the various redirect options in shell. For example if you want to run two sqlplus sessions, filter each one and output the final results to a file.
(
sqlplus -s <<EOF | awk_or_whatever_pipeline_one
dit dit dah
EOF
sqlplus -s <<EOF | awk_or_whatever_pipeline_two
dit dit dah
EOF
) 2>&1 >my_filename
Back to the point. In Oracle you may wish to check that v$session is current before issuing the kill. Don't forget to escape v\$session if it's mentioned in a unix shell.