-1
sybase    1215 30224  0 20:44 pts/3    00:00:00 grep dataserver
sybase    6138  6137  0 Feb04 ?        00:28:10 /u01/sybase/ASE15_0/ASE-15_0/bin/dataserver -d/u01/sybase/ASE15_0/data/aashish1_master.dat -e/u01/sybase/ASE15_0/ASE-15_0/install/aashish1.log -c/u01/sybase/ASE15_0/ASE-15_0/aashish1.cfg -M/u01/sybase/ASE15_0/ASE-15_0 -s**aashish1**
sybase    7671     1  0 Jan27 ?        00:55:50 /u01/sybase/ASE15_0/ASE-15_0/bin/dataserver -s**chaitu** -d/u01/sybase/ASE15_0/data/chaitu_master.dat -e/u01/sybase/ASE15_0/ASE-15_0/install/chaitu.log -c/u01/sybase/ASE15_0/ASE-15_0/chaitu.cfg -M/u01/sybase/ASE15_0/ASE-15_0
sybase   29479 29478  0 17:28 ?        00:00:33 /u01/sybase/ASE15_0/ASE-15_0/bin/dataserver -d/u01/sybase/ASE15_0/data/asdfg_master.dat -e/u01/sybase/ASE15_0/ASE-15_0/install/asdfg.log -c/u01/sybase/ASE15_0/ASE-15_0/asdfg.cfg -M/u01/sybase/ASE15_0/ASE-15_0 -s**asdfg** -psa
sybase   29617 29616  0 17:48 ?        00:00:33 /u01/sybase/ASE15_0/ASE-15_0/bin/dataserver -d/u01/sybase/ASE15_0/data/parbat.dat -e/u01/sybase/ASE15_0/ASE-15_0/install/parbat.log -c/u01/sybase/ASE15_0/ASE-15_0/parbat.cfg -M/u01/sybase/ASE15_0/ASE-15_0 -s**parbat**
sybase   29789 29788  0 17:57 ?        00:00:28 /u01/sybase/ASE15_0/ASE-15_0/bin/dataserver -d/u01/sybase/ASE15_0/data/ab123_master.dat -e/u01/sybase/ASE15_0/ASE-15_0/install/ab123.log -c/u01/sybase/ASE15_0/ASE-15_0/ab123.cfg -M/u01/sybase/ASE15_0/ASE-15_0 -s**ab123** -psa
[sybase@linuxerp scripts]$

I want to get the dataserver name from OS level itself without connecting to the Database.

ps -ef | grep dataserver

will get the server running or not

I tried to keep the output in a file and used grep -v on the file

Since the server name was not in exactly position, it is difficult to get the servername .

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
  • ps -ef will only get the running servers. If you want servers that aren't running you will need to check the $SYBASE/interfaces, or the RUN_servername files typically in $SYBASE/$SYBASE_ASE/install – Mike Gardner Feb 10 '17 at 15:05

1 Answers1

0

There are a couple of ways you can grab that information. One would be to pipe the grep output and use a regular expression:

ps -ef | grep dataserver | grep -oh '\-s[[:alnum:]]*' which should output something like this:

-saashish1
-schaitu
-sasdfg
-sparbat
-sab123

Another would be to use the showservers utility that comes installed with ASE, which outputs very similar to ps -ef but with CPU & Memory information as well as including other database servers such as the backup server, xp server, etc.

%> showserver

USER        PID %CPU %MEM   SZ  RSS TT STAT START  TIME COMMAND
user114276  0.0  1.7  712 1000 ?  S    Apr  5514:05 dataserver -d greensrv.dat -sgreensrv -einstall/greensrv+_errorlog 
sybase    1071  0.0  1.4  408  820 ?  S    Mar 28895:38 /usr/local/sybase/bin/dataserver -d/dev/rsd1f -e/install/errorlog
user128493  0.0  0.0 3692    0 ?  IW   Apr  1  0:10 backupserver -SSYB_BACKUP -e/install/backup.log -Iinterfaces -Mbin/sybmultbuf -Lus_english -Jiso_1

And then pipe that into the same grep to get the information you are trying to find.

If you want to cut the -s off the front, to just get the servername itself, then you can pipe that into tr or cut.

Using tr you can tell it to delete -s from each line:

| tr -d '\-s'

Using cut you can tell it to print everything from the 3rd character to the end of the word:

| cut -c3-

Both of these will output your server names like this:

aashish1
chaitu
asdfg
parbat
ab123

Check this Question for information on using grep to grab single words.

Community
  • 1
  • 1
Mike Gardner
  • 6,611
  • 5
  • 24
  • 34