Operating System - HP-UX
1834752 Members
3145 Online
110070 Solutions
New Discussion

Re: FInd PC Name or IP Address

 
Bob Ferro
Regular Advisor

FInd PC Name or IP Address

I have a Unix 11i system running BaanIV as the application. The user connects to BaanIV thru a Windows Client tool. Under normal conditions, I could do a grep and find the PC name for the user. This was very helpful when you wanted to identify who is logged on and where. I had to make a change and substitute a Unix script to interface between the PC and Unix. This was so a user could not log on more than their max amounts. By doing this I cannot find out where a user is logged at. Is there a way to query the Unix system to find either the PC name or the IP address? I tried netstat but to no avail. Our clients are running either NT or 2000.
Thanks,
Bob
11 REPLIES 11
Patrick Wallek
Honored Contributor

Re: FInd PC Name or IP Address

How are they logging in? Do the users show up if you do a 'who' command? If so, try 'who -R'.

If you have lsof installed, that may be able to do it as well.
Geoff Wild
Honored Contributor

Re: FInd PC Name or IP Address

Used to use Baan, 3.1....

Had a script like this:

#!/bin/sh
# triton31.usage
#
# Geoff Wild October 1998
# Set up environment
BSE=/usr6/triton3.1/bse
BSE_TMP=$BSE/tmp
PATH=$PATH:$BSE/bin
export BSE BSE_TMP PATH
# Set up logfile
logfile=/tmp/triton.usage.log
if [ -f $logfile ];
then
rm $logfile
touch $logfile
else
touch $logfile
fi
echo `date` >>$logfile 2>&1; /usr6/triton3.1/bse/bin/licmon6.1 -w|grep -v SERVER| wc|awk '{print "T
here are",$1, "Triton 3.1 Users"}' >>$logfile 2>&1


That may give you some idea - I'm sure there is a command to list userids connected...

Rgds...Geoff


Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Bob Ferro
Regular Advisor

Re: FInd PC Name or IP Address

WHen I do a who nothing shows. I will try the Baan/Unix script.
Geoff Wild
Honored Contributor

Re: FInd PC Name or IP Address

Maybe something like this:
#!/bin/sh
#
#
#
# Modification Log
#
# Edited by Description Date
#
#


# Setup Environment
#

BSE=/usr6/triton3.1/bse
BSE_TMP=$BSE/tmp
PATH=$PATH:$BSE/bin
export BSE BSE_TMP PATH

#
#
date
licmon6.1 << EOF | grep -v -E 'licmon|END'
u
quit
EOF

licmon6.1 << EOF | awk '{print $3}'|grep -v -E 'jamaica|USER'| awk '{FS="."} {print $1}' | sort | uniq -c | sort -nr | grep -vE "^ [0-9] $"
who
quit
EOF

Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Abdul Rahiman
Esteemed Contributor

Re: FInd PC Name or IP Address

Bob,

We use baan here too on different platforms. I normally use the netstat comand to find the client bshell user's hostname or ipaddress. You mentioned that "I tried netstat but to no avail.", ca you elaborate on that.

What I normally do is,
# netstat -an | grep "\.7150" | awk {'print $5'} --> for users signing on via blogind method
or
# netstat -an | grep "\.512" | awk {'print $5'} --> for logged on via rexec.

regds,
Abdul.
No unix, no fun
Norman_21
Honored Contributor

Re: FInd PC Name or IP Address

did you try this:
#last -R
"Attitudes are contagious, is yours worth catching"/ My first point was given by SEP on January 31, 2003
Bob Ferro
Regular Advisor

Re: FInd PC Name or IP Address

Thanks for everyone answer but the netstat give me the IP address but not the hostname (PC name). Normally when Baan use the bshell6.1 program, you can do a grep on a username and find the hostname, i.e. bferro@mypc where mypc is my hostname. When you intercept this process with a script, you look that visibility. How does Baan get the info?

Thanks again
Bob
Jeff Schussele
Honored Contributor

Re: FInd PC Name or IP Address

Hi Bob,

If you drop the -n from the netstat command it will attempt hostname lookups & display that instead. Of course the PCs *must* be in DNS to get a name returned. If the IP is not resolvable then netstat will return the IP.

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Bob Ferro
Regular Advisor

Re: FInd PC Name or IP Address

Hi Jeff,

Most of the PCs use DHCP (dynamic IP). The funny thing is that if you grep the Unix/BaanIV user name, the hostname or PC name would be displayed. Now that I use a Unix script instead of the BaanIV bshell6.1 program, I don't see it anymore.
Abdul Rahiman
Esteemed Contributor

Re: FInd PC Name or IP Address

Could you post the unix script that you are using to invoke the bshell pls..?

~Abdul.
No unix, no fun
Bob Ferro
Regular Advisor

Re: FInd PC Name or IP Address

The Unix script is attached and the following is the results of the "ps -ef | grep rroth" command where rroth is the userid.

rroth 25266 623 0 14:29:50 ? 0:00 /bin/ksh /baan/bse/bin/script6.2 -1 545 0 1
rroth 25275 25266 0 14:29:51 ? 0:06 /baan/bse/bin/bshell -1 545 0 1
rroth 25276 25275 0 14:29:53 ? 0:00 oracle8 (rroth:25275/PIPE) 25275 321 10 11
rroth 25278 1 0 14:29:53 ? 0:00 oraclebaanIV (DESCRIPTION=(LOCAL=YES)(SDU=8192)(TDU=8192)(AD