Subject: | |
From: | |
Reply To: | |
Date: | Wed, 19 Dec 2007 12:02:36 -0500 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
On Dec 19, 2007, at 11:44 AM, Steven D. Majewski wrote:
> I've got a small shell script that executes an applescript via
> osascript
> to set the terminal background & foreground colors ( looking them up
> in
> /usr/X11R6//lib/X11/rgb.txt if they are names rather than numbers. )
>
> I would like to extend this script to work with iTerm.
>
> Any ideas on the best way to figure out whether Terminal.app or
> iTerm.app
> is the 'owner' of the tty where the shell script is executing ?
>
> The only way I can think of is using 'lsof' , and that seems like a
> pretty
> indirect route:
>
> $ tty
> /dev/ttyp1
>
> $ lsof -c Terminal | grep '/dev'
> Terminal 238 sdm7g 0r VCHR 3,2 0t0 42135940 /dev/
> null
> Terminal 238 sdm7g 1w VCHR 0,0 0t906 42136580 /dev/
> console
> Terminal 238 sdm7g 2w VCHR 0,0 0t906 42136580 /dev/
> console
> Terminal 238 sdm7g 11u VCHR 5,1 0t2701 42376836 /dev/
> ptyp1
>
>
> The shell's tty and Terminal.app's pty are the slave/master pair of
> pseudo
> terminal devices -- different names, but I'm guessing the last
> digits will
> always match up.
>
>
> Any other ideas ?
>
> -- Steve Majewski / UVA Alderman Library
greetings
Just a thought; i do this with my ssh connections
do shell script " whoami "
root
scan ps -aux for the tty or process and it will list the user
connections.
ps -aux | grep ssh
root 10310 0.0 -0.1 30316 1100 ?? S 11:46AM 0:00.08 /
usr/sbin/sshd -i
another is as the user ps the user processes.
example.
nc1-100:~ drfoo$ ps
PID TTY TIME CMD
15450 ttys000 0:00.01 -bash
15459 ttys001 0:00.01 -bash
15504 ttys001 0:00.39 ssh -l root mail2
or something like that.
man ps for more ideas.
|
|
|