1827109 Members
3606 Online
109714 Solutions
New Discussion

Re: ODBC Connections

 
Tracey
Trusted Contributor

ODBC Connections

Is there some way to tell via the UNIX shell that there is an ODBC connection to a database on the machine? I am running HPUX 10.20, the database is Ingres 6.4. I know how I can do it via the database monitor applications, but I will have to write a long complicated script, and I was (of course) wishing for an easier way.
3 REPLIES 3
CHRIS_ANORUO
Honored Contributor

Re: ODBC Connections

Yes, you can use lsof, download and install lsof from this site if you don't have it already installed : http://gatekeep.cs.utah.edu/hppd/hpux/Sysadmin/lsof-4.51/
#lsof |grep databasename|pg . Run this at the command prompt.
When We Seek To Discover The Best In Others, We Somehow Bring Out The Best In Ourselves.
Richard Darling
Trusted Contributor

Re: ODBC Connections

Tracey, try

root:L1000>:lsof -iTCP:7001
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
usqlsd 13732 root 3u inet 0x10243fe68 0t0 TCP *:7001 (LISTEN)

I know port 7001 is being used by my ODBC program usql, and it is TCP.

If you don't have a copy and are running 64 bit, here is the binary in gzip format. If you do a search through this site for lsof there is a ton of info.
Richard Darling
Trusted Contributor

Re: ODBC Connections

Tracey, to list the files in use by my OBDC I use, with partial listing:

root:L1000>:lsof -c usqls
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
usqlsd 13732 root cwd VDIR 64,0x5 1024 8760 /usr/usqls/bin
usqlsd 13732 root txt VREG 64,0x5 1200244 11926 /usr (/dev/vg00/lvol5)
usqlsd 13732 root mem VREG 64,0x5 127445 704 /usr/lib/libm.1
usqlsd 13732 root mem VREG 64,0x5 126976 721 /usr (/dev/vg00/lvol5)
usqlsd 13732 root mem VREG 64,0x7 41183 1162 /opt/cobol/cobdir/cobl
ib/libmfo.1
usqlsd 13732 root mem VREG 64,0x7 165171 1165 /opt/cobol/cobdir/cobl
ib/liboops.1
usqlsd 13732 root mem VREG 64,0x7 20523 1159 /opt/cobol/cobdir/cobl
ib/libmbcs.1
usqlsd 13732 root mem VREG 64,0x7 197443 1149 /opt/cobol/cobdir/cobl
ib/libfhutil.1

If you are looking for a specific users:
root:L1000>:lsof -u loumf
root:L1000>:lsof -u loumf
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
ksh 2296 loumf cwd VDIR 64,0x9 32768 2 /usr/FACDTA
ksh 2296 loumf txt VREG 64,0x5 163840 11843 /usr/bin/ksh
ksh 2296 loumf mem VREG 64,0x5 679936 17954 /usr/lib/libnsl.1
ksh 2296 loumf mem VREG 64,0x5 126976 2397 /usr/lib/libxti.2
ksh 2296 loumf mem VREG 64,0x5 20480 693 /usr/lib/libdld.2
ksh 2296 loumf mem VREG 64,0x5 1462272 16647 /usr/lib/libc.2
ksh 2296 loumf mem VREG 64,0x5 126976 15483 /usr/lib/dld.sl