Extracting specific info finger command


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Extracting specific info finger command
# 8  
Old 01-27-2012
Code:
finger $LOGNAME | grep -A1 $a | tail -1

# 9  
Old 01-27-2012
sorry i am not getting how your command will work , its not a complet one
# 10  
Old 01-27-2012
The output of finger $LOGNAME from my system doesn't appear to be in the same format as yours.
This is how I get it, in a single line:
Code:
$ a=`tty | sed 's_/dev/__'`; finger $LOGNAME | grep $a
On since Mon Dec 26 05:47 (GMT) on pts/2 from xxx.xxx.xx.xx

So, please post the exact output from your system
Code:
a=`tty | sed 's_/dev/__'`; finger $LOGNAME | grep -A1 $a | tail -1

And please use code tags.
# 11  
Old 01-27-2012
Please reveal what Operating System and version you have and what Shell you are using.

On your previous threads we never understood how this connection works.
https://www.unix.com/shell-programmin...inal-unix.html

If these connections show as pts connections then the output from the "last" command would be easier to work with than "finger".

Code:
last -R -20 ${LOGNAME} | grep "still logged in"

(The exact syntax of "last" will depend on your Operating System).


If this is connecting to a database engine this sort of information would normally be available to the database engine.
# 12  
Old 01-29-2012
I will give more details on this
Code:
 
finger $LOGNAME

output
--------
Login name: ab67999 In real life: felisaona
Site Info: abc,zxccb,100089
Directory: /home/ab67999 Shell: /bin/ksh
On since Jan 30 02:03:20 on pts/2
from psxjj10067.emea.nsoot.net
On since Jan 30 02:04:31 on pts/3, 13 seconds Idle Time
from psxjj90067.emea.nsoot.net
No Plan.

and output for below stuff
Code:
a=`tty | sed 's_/dev/__'`; finger $LOGNAME | grep $a

output
On since Jan 30 02:03:20 on pts/2

as you can see id ab67999 logged in from 2 different machine psxjj10067.emea.nsoot.net & psxjj90067.emea.nsoot.net and hence by getting pts from second command we conclude that psxjj10067.emea.nsoot.net is the current machine console and I want to extract that ..
# 13  
Old 02-01-2012
I was able to extract using below command , but I feel its too long . Please let me know if there is efficient way that anyone can think of
I have give out put as well for each variable (shell is ksh and uname - a has output as follows "AIX mdddddd01u 1 6 00JKM1223C00")
Note that I am exexuting this query from an application and hence command who,tty cannot be used

Code:
a=`ps | grep "ksh" | tail -1 | cut -f4 -d' '`;b=`finger $LOGNAME | grep $a`;c=`finger $LOGNAME` ;d=`echo $c | awk '{gsub(/On/,"\nOn");print}' | grep "$b" | cut -f9 -d' ' | tail -1`;echo $LOGNAME@$d

output
---------
ab89900@jalswonx0045.emea.nsroot.net
Code:
[ab89900]/home/ab89900>echo $a

pts/1
Code:
[ab89900]/home/ab89900>echo $b

On since Feb 01 04:11:50 on pts/1
Code:
[ab89900]/home/ab89900>echo $c

Login name: ab89900 In real life: lamsan Site Info: kamsla,3239923@United Kingdom,ab89900 Directory: /home/ab89900 Shell: /bin/ksh On since Feb 01 04:11:50 on pts/1 from jalswonx0045.emea.nsroot.net No Plan.
Code:
[ab89900]/home/ab89900>echo $d

jalswonx0045.emea.nsroot.net
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Have a situation while extracting info

i have a text file which i am generating from few sqls. format is like : col1 col2 col3 col4 col5 1001 DONE ABC 17-sep-14 12:02:05 1001 DONE ABC 17-sep-14 12:02:05 1001 DONE ABC 17-sep-14 12:02:55 1001 REDONE ABC ... (6 Replies)
Discussion started by: deepakiniimt
6 Replies

2. Solaris

Extracting HBA Card Hardware info

Hello, I am very new to solaris so please bear with me. I have 2 machines in question. For both I am trying to get the HBA Card Hardware information such as: HBA Model Name HBA Firmware version HBA Port details HBA Driver details First machine is a Solaris 10. When I execute fcinfo... (6 Replies)
Discussion started by: flagman5
6 Replies

3. UNIX for Dummies Questions & Answers

Finger command help

Hi Does anyone know if there is anyway of doing the finger command for all user id's in my enviroment. What I need to obtain is the full names of all users on the system. I know if i do the finger command with no arguments it will list users currently logged in, but i need all users... ... (2 Replies)
Discussion started by: m3y
2 Replies

4. UNIX for Advanced & Expert Users

finger command

I want to know the correct version of how i should use the finger command in this example below.(os is debian lenny) (nymserver.pl is located in /home/nymserv directory.) the two versions are : (in/etc/inetd.conf) finger stream tcp nowait nymuser /usr/nym/nymserv nymserv... (3 Replies)
Discussion started by: xstation
3 Replies

5. UNIX for Dummies Questions & Answers

Extracting spec info from finger.

Hi everyone, I'm trying to extract the user name and full name from the finger command without using sed or awk. Any pointers? Thanks in advance. (6 Replies)
Discussion started by: franny
6 Replies

6. UNIX for Dummies Questions & Answers

Extracting specific info from finger command

Hello all, my unix is bash based and the finger command output is: Login Name Tty Idle LoginTime Office amos.john Amos John pts/26 1 Dec 5 16:18 (77.100.22.07) What am trying to achieve is extract the Login (amos.john) and Name (Amos John) from this output without using awk or sed. ... (1 Reply)
Discussion started by: franny
1 Replies

7. Shell Programming and Scripting

help in finger command.

Hi, iam using sunsolaris. when you type finger command -- it dispalys information about local and remote users. but here it shows as can't stat /dev/gold:8664 can anybody help what is the solution for this error. previously the output came. thanks, shan (1 Reply)
Discussion started by: shanshine
1 Replies

8. UNIX for Advanced & Expert Users

finger command

Hello all, Here is what I am trying to do. If a user exist, then send an echo "EXIST" or else "DOES NOT EXIST". (under HP-UX) Kind of: #!/usr/bin/sh USER=mylogin finger $USER if $? = 0 then echo "EXIST"" else echo "DOES NOT EXIST" fi (10 Replies)
Discussion started by: qfwfq
10 Replies

9. Shell Programming and Scripting

How to unset 'finger' info?

Hi, Command "chfn" can be used to change finger information.. can anybody tell me how to unset i mean reset the same finger information. Thanks in advance, Chanakya (3 Replies)
Discussion started by: Chanakya.m
3 Replies

10. UNIX for Dummies Questions & Answers

Extracting Info

i have a file that contain lines like this 9.4.7.8.5.7.9.0.5.7.1.2.msisdn.sub.cs. 1 IN CNAME SDP01.cs. there are about 50,000 lines like this in the files i want to the extract the digits from the above line like:- 947857905712 OS Solaris9 (3 Replies)
Discussion started by: muneebr
3 Replies
Login or Register to Ask a Question