If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
I am trying to write a shell script that can let me manage users on a database server more aggressively -- I do understand the consequences of doing such things so please keep focused.
If I want to execute something like sp_who in Sybase, what is the best method to return that data into an array? From there, I want to be able to find specific username's which I would like to kill their spid's.
If anybody has advice on best way to handle it, or a better approach to managing user accounts that I need to 'boot', please let me know.
I don't remember well sybase, but what you want is something similar to this:
Code:
#!/bin/ksh
# boot_users.sh
#
all_usrs=`
isql -u xxx -p yyy <<!EOF
exec sp_who; -- Here you execute the proc
exit
!EOF
`
for usr in $all_usrs
do
# Here you code to check for bad user
# ..
# find spid
spid=`ps -u $usr|awk '{print $1;}'`
# Kill the task
for p in $spid
do
kill -9 $p
done
done
PS: Execute sybase in 'silent mode'. This code is only as example, there might be better ways.
__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
When you say execute in 'silent mode', what exactly do you mean?
Is that something not indicative of what you have posted above?
Thanks again for your help,
-C
In Oracle you can invoke the SQL interface (sqlplus) with a 'silent' option which tell sqlplus to not send 'unwanted' messages to the terminal (like software version, etc...). I just thought that maybe sybase had something similar.
__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb