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.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > help in shell script, please

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-03-05, 13:57
sardonux sardonux is offline
Registered User
 
Join Date: Jan 2005
Location: Washington, DC
Posts: 5
Question help in shell script, please

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.

Thanks!
Reply With Quote
  #2 (permalink)  
Old 01-03-05, 15:37
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,456
Cool

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
Reply With Quote
  #3 (permalink)  
Old 01-03-05, 15:56
sardonux sardonux is offline
Registered User
 
Join Date: Jan 2005
Location: Washington, DC
Posts: 5
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
Reply With Quote
  #4 (permalink)  
Old 01-03-05, 17:03
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,456
Cool

Quote:
Originally Posted by sardonux
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On