who command from non terminal in unix


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting who command from non terminal in unix
# 1  
Old 01-26-2012
who command from non terminal in unix

I was executing a command "who -ms" from a CHUI application but i get below message,
It seems that who command can be executed only when we are logged directly in unix box as we have terminal.
Is there a way to get rid of this problem , or anyother command where i can get machine name of the terminal from where i am logged in?
Code:
process not attached to terminal                                               x
xUsage: who [-AabdHilmpqrsTtuwX?] [am {i,I}] [file]                            x
x         -A   Accounting entries                                              x
x         -a   All (AbdHlprTtu) options                                        x
x         -b   Boot time                                                       x
x         -d   Dead processes                                                  x
x         -H   Display a header (title)                                        x
x         -l   Login processes                                                 x
x         -m   Information about current terminal (same as 'am i'              x
x         -p   Processes other than getty or user process                      x
x         -q   Quick (only user and host name)                                 x
x         -r   Run level                                                       x
x         -s   Short form (suppress Activity and PID)                          x
x         -T,w Status of tty (+ writable, - not writable, x exclusive open, ? hx
x         -t   Time changes                                                    x
x         -u,i Activity and PID of shell                                       x
x         -X   Expanded user names

Moderator's Comments:
Mod Comment Please use next time code tags for your code and data

Last edited by vbe; 01-26-2012 at 05:31 AM..
# 2  
Old 01-26-2012
the hostname command perhaps?
# 3  
Old 01-26-2012
hostname will give servername

hostname gives servername whereas I am looking for localhost
meaning for eg if i connect from any terminal to unix server , I would like to get the machine name which is used to connect and not the unix server name
# 4  
Old 01-26-2012
What connection method are you using to connect to this computer. How are you running unix commands?
What Operating System and version are you running and what Shell do you use?
If you are connecting to a database engine, what it it?

Ps. We assume that CHUI means Character-based User Interface. Some sort of Shell breakout from your application?
# 5  
Old 01-26-2012
application is CHUI built uniface

we are invoking application using shell script .

I got another way of getting the user details ie using finger which gets me details in the application , but the problem is it gets details about all the session of the user who is logged in and not only for the current one

beliow is the command which i used , I dont think who command works if i am not in console . Somehow if we can get below commadn to work for currnet session using tty and $logname and get <logname>@<machine name from where we are logged in> , it will solve the purpose.
Code:
finger -b -p $LOGNAME | grep from

any idea

Last edited by vbe; 01-27-2012 at 01:54 PM.. Reason: code tags...
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Linux

Terminal command

I need to execute apt-cdrom to designate the pendrive using LM 18.3x 'live". (instead of CD-Rom) Rick (7 Replies)
Discussion started by: 69Rixter
7 Replies

2. Shell Programming and Scripting

Execute ssh command with additional terminal command to any remote user not working script

Hello i am having an issue with bash script and this is the code now=$(cat hosts1.txt | awk '{print $2;}') while read n ;do ssh root@$now 'useradd test1; echo -e "test1\ntest1" | passwd test1 && echo "test1 ALL=(ALL:ALL) ALL" >> /etc/sudoers' When i execute only part with cat, it... (8 Replies)
Discussion started by: tomislav91
8 Replies

3. UNIX for Advanced & Expert Users

unix command for terminal - view sequences as a single line?

Hello, I'm looking for some code that will list sequences of files as a single line. ie, sequences of files like this: filename.1.ext filename.2.ext filename.3.ext filename.4.ext filename.5.ext filename.6.ext filename.7.ext filename.8.ext filename.9.ext filename.10.ext would... (6 Replies)
Discussion started by: kentm
6 Replies

4. Shell Programming and Scripting

How do I launch a command on an existing terminal in unix using PERL

Hello, I have a PERL-TK based GUI from which I want to launch a command on an existing UNIX terminal (this is also the parent terminal for this perl based gui window). The command I want to launch is interactive (there is no intention to interact with that command from the same PERL gui i.e. no... (2 Replies)
Discussion started by: AnuragJindal
2 Replies

5. Shell Programming and Scripting

Is command line invocation of gnome-terminal to run more than one command possible?

Hello, I am trying to learn how to pass something more than a one-command startup for gnome-terminal. I will give an example of what I'm trying to do here: #! /bin/bash # #TODO write this for gnome and xterm USAGE=" ______________________________________________ ${0##*/} run... (0 Replies)
Discussion started by: Narnie
0 Replies

6. UNIX for Dummies Questions & Answers

what's the terminal command to do this ?

what's the terminal command to do this ? thanks (6 Replies)
Discussion started by: aneuryzma
6 Replies

7. UNIX for Dummies Questions & Answers

Plz Help : How to use write command to execute command on some other terminal

Hi Group , I m trying to execute commands on some other system using write command but inspite of executing the commands they r passed as simple messages. - i m writing >write user-id ! ls o ctrl-d inspite of executing the command ls,other terminal shows ! ls. Thnx in advance. (2 Replies)
Discussion started by: Aashish
2 Replies

8. UNIX for Dummies Questions & Answers

Need Someone With Access To Unix Terminal

Any chance someone could look up the Whois for www.weddingchannel.la and www.art.la at the following link: whois -h whois.afilias-grs.info domainname.la Thanks in advance!!! rdm (4 Replies)
Discussion started by: rdm
4 Replies

9. UNIX for Advanced & Expert Users

connecting to unix through hyper terminal - as a dumb terminal

I just changed from windows NT to XP and I am no longer able to connect to my unix system. I used to use hyper terminal -- which acts as dumb terminal to my main frame unix system. I think one of the options used to be "direct to comX". This option isn't listed now. I use a serial port and the... (2 Replies)
Discussion started by: michelle
2 Replies
Login or Register to Ask a Question