It is not clear what you are trying to do or where the azure
text is coming from; but my understanding is that the text comes from the output of the SQL command and then gets evaluated because you are not quoting it properly.
See When to wrap quotes around a shell variable? or simply submit your code to http://shellcheck.net/ before asking for human review.
The following attempts to fix the broken quoting, the incorrect permissions, and the multiple useless cat
s.
# Don't capture to a variable; simply write directly to a file
# This also coincidentally removes one instance of broken quoting
sqlplus <code goes here> >pro.txt
# Don't use insecure permissions
chmod 644 pro.txt
# Add missing Here terminator at the end; backslash causes code to be run by su
sudo su <<\Here
cat pro.txt
# Avoid useless cat
total=$(tr -cd ' \t' <pro.txt| wc -c)
# Fix quoting
echo "$total"
i=1
# Fix quoting and useless cat
provide=$(awk -v var="$i" '{print $var}' pro.txt)
# Add missing Here terminator
Here
This code doesn't do anything useful because the variables will be gone when the sudo su
subshell exits, so there is probably more work to be done. Perhaps ask a new question where you explain what you hope to actually accomplish.
A particularly pesky problem was the lack of quoting around the here document terminator. Without it, the command substitutions would be executed by the current shell. Let me demonstrate:
sudo su <<Here
echo $(who am i)
Here
The output is you
, not root
, because the command substitution $(who am i)
is evaluated by your current shell before sudo su
runs. Quoting or backslashing the string after <<
disables this expansion, and passes the entire here document verbatim as standard input to sudo su
. See also Escaping a dollar sign in Unix inside the cat command