If you need to perform operations on the base database in shell, you can first create a corresponding function, as shown in figure
Dbstr = "Tigger/pw123 @ orcl"
Exesql ()
{
Sqlplus-S $ dbstr <EOF
Set autocommit off;
$1;
Commit;
Exit;
EOF
}
Phonelist = "13257718899"
18605518899
"
Send_sms ()
{
Pcount = 0
For phone in $ phonelist
Do
Time = "XSS" 'date + '% Y % m % d % H % m % s''
Comm_sn = "$ {time} $1 $ {pcount }"
Echo "comm_sn =$ {comm_sn }"
SQL = "insert into tab_xx alues ('" $ comm_sn "', 'arm', '" $ phone "', to_char (sysdate, 'yyyymmddhh24miss '), 'ioc _ alarm ', '2', to_char (sysdate, 'yyyymmddhh24mis'),' "$2" ', 0 )"
Exesql "$ SQL"
SQL = "insert into tab_xx values ('" $ comm_sn "', 'arm', '" $ phone "', to_char (sysdate, 'yyyymmddhh24miss '), 'ioc _ alarm ', '2', to_char (sysdate, 'yyyymmddhh24mis'),' "$2" ', 0 )"
Exesql "$ SQL"
Pcount = 'expr $ pcount + 1'
Echo "pcount =$ {pcount }"
Sleep 1
Done
}
Send_sms "01" $ msg