Computing.Net > Forums > Unix > Unix script for 'sp_who'

Unix script for 'sp_who'

Reply to Message Icon

Original Message
Name: AceKnocks
Date: October 7, 2005 at 07:06:05 Pacific
Subject: Unix script for 'sp_who'
OS: solaris
CPU/Ram: n.a
Comment:

Hi,
I want to create a unix script which will keep on executing 'sp_who' for sybase database (name = my_sybase) in every 5 mins.

Please help


Report Offensive Message For Removal


Response Number 1
Name: nails
Date: October 7, 2005 at 09:18:30 Pacific
Subject: Unix script for 'sp_who'
Reply: (edit)

Years ago, I was a sybase admin, but no more. I do have this stub program left over which you can probably modify to call 'sp_who'.

#!/bin/ksh

SERVERNAME="TEST_SERVER"
USER="my_user"
PASSWD="my_pass"
DBNAME="my_sybase"
DBCOMMAND="eval isql -S $SERVERNAME -U $USER -P $PASSWD"
$DBCOMMAND << MSG
use $DBNAME
go
SELECT * FROM test_table
go
MSG
# end script

If you want to call it every 5 minutes, you need to set up cron. This calls my_script every 5 minutes:

# untested
*/5 * * * * my_script



Report Offensive Follow Up For Removal

Response Number 2
Name: Dlonra
Date: October 7, 2005 at 11:51:24 Pacific
Subject: Unix script for 'sp_who'
Reply: (edit)

cron if you want script to run 24/7.
to run a script you can eyeball:
#!/bin/ksh

SERVERNAME="TEST_SERVER"
USER="my_user"
PASSWD="my_pass"
DBNAME="my_sybase"

while [ true ]
do

DBCOMMAND="eval isql -S $SERVERNAME -U $USER -P $PASSWD"
$DBCOMMAND << MSG
use $DBNAME
go
SELECT * FROM test_table
go
MSG
# end script

sleep 300
done


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Unix script for 'sp_who' 

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 3 Days.
Discuss in The Lounge