Extracting specific info finger command


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Extracting specific info finger command
# 1  
Old 01-26-2012
Extracting specific info finger command

how to extract user machine name for current terminal using finger command

below command gives machinename for all session , is it possible to filter it to only currernt terminal ?
Code:
finger -b -p $LOGNAME | grep from


Last edited by methyl; 01-27-2012 at 08:40 AM.. Reason: please use code tags
# 2  
Old 01-26-2012
try the who command

who <user>
# 3  
Old 01-27-2012
cannot use who

sorry forgot to mention cant use who as this is not from console

---------- Post updated at 11:20 PM ---------- Previous update was at 10:12 PM ----------

Let me add some more details to this ,
by command A)"finger $LOGNAME" I can get all session for the user as shown below
by command B)" a=`tty | sed 's_/dev/__'` ; finger $LOGNAME | grep $a " I can get my logged in terminal ,
but dont know how to extrat the next line "from <localhost>"

A)command prompt-> finger $LOGNAME
Login name: <loginname> In real life: <name>
Site Info: <sit info>
Directory: <homedir> Shell: /bin/ksh
On since Jan 27 01:37:28 on pts/0
from <localhost>
On since Jan 27 04:02:39 on pts/1, 4 minutes 19 seconds Idle Time
from <localhost>
No Plan.

B)command prompt-> a=`tty | sed 's_/dev/__'` ; finger $LOGNAME | grep $a
On since Jan 27 01:37:28 on pts/0
Moderator's Comments:
Mod Comment Please use next time code tags for your code and data

Last edited by vbe; 01-27-2012 at 01:57 PM..
# 4  
Old 01-27-2012
Code:
finger $LOGNAME | grep $a | awk '{print $(NF-1), $NF}'

# 5  
Old 01-27-2012
gives only tty

this gets tty how we will get "from <machinename> which is on next line??
# 6  
Old 01-27-2012
Please post the output of
finger $LOGNAME | grep $a. As there's no "next line" when I run this on my system.
# 7  
Old 01-27-2012
When we run command "finger $LOGNAME" we get below details
Code:
command ->finger $LOGNAME
output -> Login name: abc In real life: lal
             Site Info: details
             Directory: <homedire-> Shell: <echo shell>
             On since Jan 27 06:36:07 on pts/0, 2 minutes 33 seconds Idle Time
             from <machine a>
             On since Jan 27 06:51:44 on pts/2
             from <machine b>
               On since Jan 27 06:45:19 on pts/7, 10 minutes Idle Time
               from <machine c>

we get 3 machines used to connect but to filter the current session I am using below stuff
Code:
Command -> a=`tty | sed 's_/dev/__'` ; finger $LOGNAME | grep $a
output -> On since Jan 27 06:36:07 on pts/0

But as you can see I need to extract "from <machine a>" from 1st command whcih is matching tty , how tthis can be done???

Last edited by methyl; 01-27-2012 at 08:42 AM.. Reason: formatting please use code tags
 
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