Operating System - HP-UX
1832617 Members
3740 Online
110043 Solutions
New Discussion

Re: Check the server login

 
SOLVED
Go to solution
peterchu
Super Advisor

Check the server login

We have one database that run on the hp unix server , many users will login to the system from two different locations eg. location A and location B ( location B is oversea ) , because the users at location B is through the VPN to connect to the database so it need to use a specific TERM setting ( eg. TERM=vt110 ) , the location A will use TERM=vt220 . Both locations use the same script to connect to the database .
I want to ask is it possible the system can check if the user is from location A , it will connect the database with TERM=vt220 , and if the user is from location B , it will connect the database with TERM=vt110 ? thx in advance.
2 REPLIES 2
Steven E. Protter
Exalted Contributor
Solution

Re: Check the server login

This command:

DISPLAY=$(who -m -u | awk '{print $8}')

The who part routed to awk(inside parens) will let you see exactly where the user logged in from and take appropriate action.

I have it in /etc/profile

I'm using to set X terminal display, but the information is quite useful.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
RAC_1
Honored Contributor

Re: Check the server login

This is very much possible.
Something like follows in /etc/profile.
ip_address=$(who -um|awk '{print $NF}')

if [ ${ip} = "vpn_ip" ]
then
export TERM=vt100
elseif
if [ 4{ip} = "other_ip" ]
then
export TERM=vt220
fi
fi

Anil
There is no substitute to HARDWORK