Answer the question
In order to leave comments, you need to log in
How to escape the $ character and other characters in a bash script?
There is a bash script with an sql query to the Oracle database. When executed, an error is thrown, which is true, since there are service characters in the request. How to shield them correctly?
#!/bin/bash
HOST=db.local
MAILHEADER="Content-Type: text/html; charset=UTF-8; Importance: high X-Priority: 1 (Highest) X-MSMail-Priority: High"
MAILBODY="Хост: <b>$HOST</b><br>
Запрос: <b>пользователи</b><br>
Дата: <b>$(date)</b><br>
<br>"
SQL=`
sqlplus -s system/[email protected] << EOF
set linesize 3800
set pagesize 60
select distinct action from v$session where action like '%FRM%' order by action;
/
EOF
`
SQLOUTPUT="<pre>$SQL</pre>"
echo "$MAILBODY $SQLOUTPUT" | mail -s "$(hostname)" -a "$MAILHEADER" [email protected]
SQL=`
sqlplus -s system/[email protected] << EOF
set linesize 3800
set pagesize 60
select distinct action from v$session where action like '%FRM%' order by action;
/
EOF
`
SQL=$(
sqlplus -s system/[email protected] << EOF
set linesize 3800
set pagesize 60
select distinct action from v\$session where action like '%FRM%' order by action;
/
EOF
)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question