Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2005
    Location
    Washington, DC
    Posts
    5

    Question Unanswered: 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!

  2. #2
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    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

  3. #3
    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

  4. #4
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •