[20190419]bash單雙引號問題.txt
[20190419]bash單雙引號問題.txt
--//上午除錯bash shell時遇到的問題。
$ sqlplus -s -l / as sysdba <<< '@ shared_latch.txt "test shared non-parent l0" 1 1 2 x 1' >| /tmp/xx.txt
$ cat /tmp/xx.txt
old 1: select decode(lower('&&5'),'s',8,'x',16,'8',8,'16',16) vmode from dual
new 1: select decode(lower('x'),'s',8,'x',16,'8',8,'16',16) vmode from dual
VMODE
----------
16
old 1: SELECT addr laddr FROM v$latch_parent WHERE NAME='&&1'
new 1: SELECT addr laddr FROM v$latch_parent WHERE NAME='test shared non-parent l0'
LADDR
----------------
0000000060009A18
Statement processed.
Function returned 1
Function returned 0
--//沒有問題。如果寫成指令碼如下,我想使用<<<語法的主要原因是shared_latch.txt指令碼最後沒有exit語句。
--//如果我直接這樣寫sqlplus -s -l / as sysdba @ shared_latch.txt "test shared non-parent l0" 1 1 2 x 1
--//在完成後是無法退出的。
$ cat shared_latch.txt
/* 引數如下: @ shared_latch.txt latch_name willing why where mode sleep_num */
--//connect / as sysdba
col laddr new_value laddr
col vmode new_value vmode
select decode(lower('&&5'),'s',8,'x',16,'8',8,'16',16) vmode from dual ;
SELECT addr laddr FROM v$latch_parent WHERE NAME='&&1';
oradebug setmypid
oradebug call kslgetsl_w 0x&laddr &&2 &&3 &&4 &vmode
host sleep &&6
oradebug call kslfre 0x&laddr
--//exit
--//如果寫成如下:
$ cat p7.sh
#! /bin/bash
vdate=$(date '+%Y%m%d%H%M%S')
echo $vdate
a="$1"
echo $a
source peek.sh "$1" 20 | timestamp.pl >| /tmp/peekx_${vdate}.txt &
sqlplus -s -l / as sysdba <<EOF >| /tmp/latch_free_${vdate}.txt &
$(seq 20 | xargs -I {} echo -e '@latch_free \n host sleep 1')
EOF
sleep 1
# 引數如下: @ exclusive_latch.txt latch_name willing why where sleep_num
sqlplus / as sysdba <<< '@ shared_latch.txt "$a" 1 4 5 x 10' >| /tmp/xx.txt &
p=$!
strace -fttT -p $p -o /tmp/pp_${vdate}_${p}.txt > /dev/null &
sleep 2
sqlplus / as sysdba <<< '@ shared_latch.txt "$a" 1 6 7 s 5' >> /tmp/xx.txt &
p=$!
strace -fttT -p $p -o /tmp/pp_${vdate}_${p}.txt > /dev/null &
wait
--//檢查 /tmp/xx.txt 內容,可以發現帶入的內容並沒有轉換。
...
old 1: SELECT addr laddr FROM v$latch_parent WHERE NAME='&&1'
new 1: SELECT addr laddr FROM v$latch_parent WHERE NAME='$a'
--//可以發現外面的單引號發生作用,導致裡面的雙引號的內容不會轉換,如何解決這個問題呢?
--//修改如下正常:
$ cat p7.sh
#! /bin/bash
vdate=$(date '+%Y%m%d%H%M%S')
echo $vdate
a="$1"
echo $a
source peek.sh "$1" 20 | timestamp.pl >| /tmp/peekx_${vdate}.txt &
sqlplus -s -l / as sysdba <<EOF >| /tmp/latch_free_${vdate}.txt &
$(seq 20 | xargs -I {} echo -e '@latch_free \n host sleep 1')
EOF
sleep 1
# 引數如下: @ exclusive_latch.txt latch_name willing why where sleep_num
sqlplus / as sysdba <<< "@ shared_latch.txt '"$a"' 1 4 5 x 10" > /dev/null &
p=$!
strace -fttT -p $p -o /tmp/pp_${vdate}_${p}.txt > /dev/null &
sleep 2
sqlplus / as sysdba <<< "@ shared_latch.txt '"$a"' 1 6 7 s 5" > /dev/null &
p=$!
strace -fttT -p $p -o /tmp/pp_${vdate}_${p}.txt > /dev/null &
wait
$ . p7.sh "test shared non-parent l0"
20190419153743
test shared non-parent l0
Process 35246 attached - interrupt to quit
Process 35249 attached
Process 35252 attached
Process 35246 suspended
Process 35255 attached - interrupt to quit
Process 35257 attached
Process 35246 resumed
Process 35252 detached
Process 35276 attached
Process 35255 suspended
Process 35246 detached
Process 35249 detached
Process 35255 resumed
Process 35276 detached
Process 35255 detached
Process 35257 detached
[1] Done source peek.sh "$1" 20 | timestamp.pl >|/tmp/peekx_${vdate}.txt
[3] Done sqlplus / as sysdba <<< "@ shared_latch.txt '"$a"' 1 4 5 x 10" > /dev/null
[4] Done strace -fttT -p $p -o /tmp/pp_${vdate}_${p}.txt > /dev/null
[5]- Done sqlplus / as sysdba <<< "@ shared_latch.txt '"$a"' 1 6 7 s 5" > /dev/null
[6]+ Done strace -fttT -p $p -o /tmp/pp_${vdate}_${p}.txt > /dev/null
[2]+ Done sqlplus -s -l / as sysdba >|/tmp/latch_free_${vdate}.txt <<EOF
$(seq 20 | xargs -I {} echo -e '@latch_free \n host sleep 1')
EOF
--//有時候這些細節問題經常搞暈掉,浪費許多時間。
$ grep sem /tmp/pp_20190419153743_352*
/tmp/pp_20190419153743_35246.txt:35249 15:37:54.919702 semctl(315588608, 34, SETVAL, 0x1) = 0 <0.000029>
/tmp/pp_20190419153743_35255.txt:35257 15:37:46.890699 semop(315588608, 0x7fff45fe1820, 1) = 0 <8.029049>
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2642106/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- linux bash中的引號:單雙引號、反撇號Linux
- HTML 單引號與雙引號HTML
- Golang的單引號、雙引號與反引號Golang
- 向SQLServer插入單引號問題SQLServer
- [20230310]nc reverse bash shell問題.txt
- 【C進階】14、單引號和雙引號
- Linux Shell 單引號 雙引號 使用區別Linux
- [20180413]bash 位置引數.txt
- [20180926]bash與分號.txt
- awk 技巧之輸出單引號和雙引號
- Oracle中單引號和雙引號的區別Oracle
- [20221111]bash eval設定變數問題.txt變數
- [20210126]bash ln建立軟連結問題.txt
- [20190419]shared latch spin count.txt
- [20210218]bash echo 建立順序號.txt
- CSS 單雙引號應用規範CSS
- [20190419]shared latch spin count 2.txt
- shell中定義變數用雙引號和單引號以及不用引號的區別變數
- [20231109]bash shell快捷鍵alt+number的問題.txt
- [20231029]使用cygwin調式bash shell引出的問題.txt
- [20231102]除錯bash shell指令碼遇到的問題.txt除錯指令碼
- [20190929]bash使用bc計算的相關問題.txt
- [20210107]編寫bash shell指令碼遇到的問題.txt指令碼
- Linux中單引號和雙引號的使用方法及注意事項!Linux
- oracle資料庫--Oracle雙引號和單引號的區別小結Oracle資料庫
- latex的雙引號 ``'
- [20231109]bbed p命令dba引數問題.txt
- [20201126]檔案相對號與絕對號問題.txt
- Python函式引數前的單星號(*)和雙星號(**)的作用Python函式
- 瞭解 Oracle 中單引號與雙引號的用法,一篇文章教會你!Oracle
- [20210318]bash test (( )) [[ ]].txt
- [20181203]bash here $.txt
- [20180930]bash shell &.txt
- 【轉】cmd中%號和雙引號轉義
- excel 如何為單元格字串前後批量新增雙引號?Excel字串
- [20221123]19cDBA_EXPRESSION_STATISTICS查詢expression_text中字串帶雙引號的問題Express字串
- Bash 指令碼:`(反引號)運算子和 $()的使用方式指令碼
- python三引號巢狀雙引號執行結果不對Python巢狀