# Execute command created from sql output

**URL:** <https://community.unix.com/t/execute-command-created-from-sql-output/213157>\
**Category:** Shell Programming and Scripting\
**Created:** [September 19, 2008, 9:54am UTC](https://community.unix.com/t/execute-command-created-from-sql-output/213157 "2008-09-19T09:54:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arkadiusz\_Masny](https://community.unix.com/letter_avatar/arkadiusz_masny/32/6_22734026db12803ebb3e059622ac3534.png) [@Arkadiusz\_Masny](https://community.unix.com/u/Arkadiusz_Masny)\
**Post date:** [September 19, 2008, 9:54am UTC](https://community.unix.com/t/execute-command-created-from-sql-output/213157/1 "2008-09-19T09:54:27Z")

</div>

Hi,

I've would like to create kill statement from sqlplus output.

So, I've modified somoene's script :

mud\_kill\_stmt=`sqlplus -s / as sysdba \<\<EOF  
select 'kill -9 ' || p.SPID || ';' statement from $process\_view p, $session\_ ......... and so on  
exit;  
EOF`  
$mud\_kill\_stmt | tr ';' '\n'

when i've ran it i have folloving output :

./kill\_processe\_oracle.sh: line 32: kill: 19819;: arguments must be process or job IDs  
./kill\_processe\_oracle.sh: line 32: kill: kill: arguments must be process or job IDs  
./kill\_processe\_oracle.sh: line 32: kill: (-9) - No such process

when i've echo'ed last command to a screen i do have following content on screen :

kill -9 19819  
kill -9 21990  
kill -9 21427

What is wrong ?

Best Regards Arek Masny

---

<div class="post-metadata">

**Author:** ![otheus](https://community.unix.com/user_avatar/community.unix.com/otheus/32/505_2.png) [@otheus](https://community.unix.com/u/otheus)\
**Post date:** [September 26, 2008, 3:56am UTC](https://community.unix.com/t/execute-command-created-from-sql-output/213157/2 "2008-09-26T03:56:40Z")

</div>

Heh, you're trying to do a tr on the output of the following command:

kill -9 19819; kill -9 21990; kill -9 21427

Take a step back and realize that you're trying to kill a process named "19819;" and "kill" and "-9".

Just eval the whole thing, or use "sh -c":

```nohighlight
eval "$mud_kill_stmt"
# or
sh -c "$mud_kill_stmt"

```
