Execute command created from sql output

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

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":

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