I am running a ksh
script from root where I switch (su
) to different users and execute the commands. But, some reason EOF does not. Here is part of my code.
This part of the code does not work su - $instance <<'EOF'
: it does not pass the $instance
instgroup=`id $instance | awk {'print $2'} | sed 's/[^ ]*( *//' | sed 's/.$//'`
db2instance=`ps -eaf | grep db2sysc |grep -v grep | awk '{print $1}' | sort
for instance in ${db2instance}; do
echo "$instance"
su - $instance <<'EOF'
echo "user -" ${instance}
echo "Checking all DB paths for Databases in $instance"
echo ""
$HOME/sqllib/db2profile
for dbname in `db2 list db directory | grep -p Indirect | grep alias | awk '{print $NF}'`
do
echo "...."
done
EOF
done
<<'EOF'
is the opening of a here document. Where is the closingEOF
on a line by itself? – Sotto Voce Nov 04 '22 at 20:29EOF
needs to be unquoted if you want variable expansion in the heredoc to take place - see for example passing and setting variables in a heredoc – steeldriver Nov 04 '22 at 23:23