TTY Reconnaissance for remote users


 
Thread Tools Search this Thread
Operating Systems AIX TTY Reconnaissance for remote users
# 1  
Old 10-28-2009
CPU & Memory TTY Reconnaissance for remote users

I'm trying to create an automated script, which (I feel) needs to be able to map local processes of a certain program with certain remote hosts. The script will know which remote host and local program it will be looking for during the mapping. Essentially the goal is to programmatically pull which programx's computerX is running on the server. A PS reveals the tty, but try as I might, I can't seem to find an AIX command that gets the PID/TTY/Username on the same line (or some other relationship) with the remote host's name. My thinking is if that b the case I can take the register name, map it to one of those and then be able to give the admins some more tools on repetitive tasks.

Essentially the set up is an AIX server with thin clients running applications which connect through ssh.

If the description is unclear somehow, I'd be happy to add more clarification.

TIA.
# 2  
Old 10-28-2009
Code:
#!/bin/sh
ps -e -o tty,pid,comm | grep <yourapp> | while read psline
do
  term=`echo $psline | awk '{ print $1 }'`
  command=`echo $psline | awk '{ print $2,$3 }'`
  wholine=`who | grep " $term " | awk '{ print $1,$6 }' | head -1`
  echo "$wholine $command"
done

(untested)

Last edited by Smiling Dragon; 10-28-2009 at 11:28 PM.. Reason: Added head -1 to the wholine - not strictly needed but cleans up the output if things get weird, and fixed $term grep
# 3  
Old 10-30-2009
thank you for the reply, but my difficuty was in pairing a locally running instance of the application with an ssh session running on a known remote host. Is there a command within aix for using pid or tty to finesse the program's remote user's host out of the system?
# 4  
Old 11-01-2009
just for posterity:

The solution eventually was to grep "lsof -i -P" for the target machine and with the target program name running, and then take the PID out of that and voila.

thanks to dragon for his response.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Python: Redirecting to tty and reading from tty

In bash, you can do something like this: #!/bin/bash echo -n "What is your name? " > /dev/tty read thename < /dev/tty How can I do the same in python? I have a python script that has the following content: #!/usr/bin/python2.7 import getpass import sys import telnetlib import... (2 Replies)
Discussion started by: SkySmart
2 Replies

2. Shell Programming and Scripting

To get total number of users and their groups in remote UNIX machine

Hi All I am trying to do ssh to different server and on the remote server for each user trying to get groups of that user but i am not getting the required result. ssh username@ip_address "for i in $( cat /etc/passwd| cut -d: -f1);do groups $i done;exit" >>abc.txt only names are... (5 Replies)
Discussion started by: Ekamjot
5 Replies

3. Shell Programming and Scripting

Create multiple users with individual passwords to users

hi, i am new to shell scripts i write a shell script to create multiple users but i need to give passwords to that users while creating users, command to write this script (1 Reply)
Discussion started by: DONFOX
1 Replies

4. UNIX for Advanced & Expert Users

Access to Remote tty cli via ssh

Scenario: I would like the ability to be able to use the cli on a client that has remotely connected to me via my ssh server in my office and use their terminal to work remotely if I am in another remote location. Ex. The client reverse ssh's to my remote ssh server in my office. ssh... (5 Replies)
Discussion started by: metallica1973
5 Replies

5. Red Hat

Chroot sftp users, remote sftp login shows wrong timestamp on files

Hello, I have a weird issue, I have RHEL 5.7 running with openssh5.2 where sftpgroup OS group is chroot. I see the difference difference in timestamp on files, when I login via ssh and SFTP, I see four hour difference, is something missing in my configuration. #pwd... (8 Replies)
Discussion started by: bobby320
8 Replies

6. Solaris

To restrict the users not to change the passwords for NIS users

Hi All, How to restrict the NIS users not to change their passwords in for NIS users?? and my NIS user is unable to login to at client location what could be the problem for this ? Any body can help me. Thanks in advance. (1 Reply)
Discussion started by: Sharath Kumar
1 Replies

7. UNIX for Advanced & Expert Users

tty changes?

I am not sure if I am using the correct terminology but somehow my tty keeps changing on me. The man pages are confusing to me on what exactly the tty is. This is what I see when I run the tty command. Could anyone explain why my tty keeps changing? ~ $ tty /dev/pts/1 ~ $ tty /dev/pts/0 (6 Replies)
Discussion started by: cokedude
6 Replies

8. UNIX for Advanced & Expert Users

Send console message to all users and tty

Hi people, i tried to search in the forum... but didnt found the answer... Sometimes i need to send a console message to all users in all tty, like reboot or shutdown does... But i cant find how to do that. Someone know? Thanks a lot (2 Replies)
Discussion started by: gfca
2 Replies

9. AIX

tty

Hi All can anyone tell me what is the meaning of tty,or give me an example of this? (1 Reply)
Discussion started by: magasem
1 Replies

10. UNIX for Dummies Questions & Answers

tty remote IP

I am fairly new to Unix Terminal outputs and I have a server that is sending print jobs to a PortServer 8 RJ45 situated in a remote location. It is working fine however we need to change the Subnet of that location and I am unable to find where the IP associated with the terminal is located. ... (4 Replies)
Discussion started by: martin_Montreal
4 Replies
Login or Register to Ask a Question