LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-12-2012, 02:05 PM   #1
listmik
LQ Newbie
 
Registered: Mar 2012
Posts: 5

Rep: Reputation: Disabled
find-switch-to-pop-up pseudoterminal


Hi,

first post, hello all.

i usually have dozens of xterminal windows open, on several workspaces. i know about the tty command and /dev/pts/X devices.

occasionally i need to terminate a process, running in lets say /dev/pts/14.

i don't want to switch through all my terminals, to find /dev/pts/14.

is there a procedure/command or so, which pops up or brings to foreground or switches to a given pts.

Thanks for your answers
mik
 
Old 03-12-2012, 02:49 PM   #2
xeleema
Member
 
Registered: Aug 2005
Location: D.i.t.h.o, Texas
Distribution: Slackware 13.x, rhel3/5, Solaris 8-10(sparc), HP-UX 11.x (pa-risc)
Posts: 988
Blog Entries: 4

Rep: Reputation: 254Reputation: 254Reputation: 254
Greetingz!

Find processes tied to 'pts/14'
Code:
ps -ef | grep 'pts/14'
Then from any terminal, just 'kill PID#' (where PID# is the Process Identification number of the process you wanted to kill)
EDIT: If you're trying to kill the xterm window that's using 'pts/14', then look for the shell running it ( -sh, -bash, -ksh ) and kill that.

Last edited by xeleema; 03-12-2012 at 02:51 PM.
 
1 members found this post helpful.
Old 03-15-2012, 10:37 AM   #3
listmik
LQ Newbie
 
Registered: Mar 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
Hi,

thanks, not exactly what i need. i need to find/locate the terminal window which represents pts/14, for e.g. listing all backgroundjobs, running in this bash session.

is there a command which brings a given pts to foreground and switches to the corresponding workspace?

Thanks.
 
Old 03-15-2012, 03:29 PM   #4
xeleema
Member
 
Registered: Aug 2005
Location: D.i.t.h.o, Texas
Distribution: Slackware 13.x, rhel3/5, Solaris 8-10(sparc), HP-UX 11.x (pa-risc)
Posts: 988
Blog Entries: 4

Rep: Reputation: 254Reputation: 254Reputation: 254
Quote:
Originally Posted by listmik View Post
is there a command which brings a given pts to foreground and switches to the corresponding workspace?
I'm not aware of any such command, though it would be specific to either the Window Manager you're using (GNOME, KDE, FluxBox, etc) or the Terminal Emulator (Konsole, Gnome Terminal, xterm, etc).

Never seen a command that did anything like that. Closest would be just Alt-Tab'ing around till you found a Terminal with 'pts/##' in the title.

How to Get the Terminal Number in an Xterm Window's Title
You could add the following to your shell's start-up file (.kshrc, .bashrc, .bash_profile, .profile, etc).
This is not just 'drop-in' code, only an example of how you would get the 'pts/#' in the title of a Terminal.
(Note that my .kshrc is about 700 lines long, and various things get collected/defined, then wind up in my Title)
Code:
TTY=$( /usr/bin/tty )   # Stores the full name of the TTY
TTY_DEV=${TTY##*/dev/}  # Cuts-out the "/dev/" prefix, which leaves "pts/0", "console", or "ttyUSB0"
TITLE="${TTY_DEV} "     # Here we could put other env vars that we want to display in a terminal's title....
print "\033]0;${TITLE}\007\c"  # Actually changes the Terminal's title.
 
Old 03-22-2012, 03:50 AM   #5
listmik
LQ Newbie
 
Registered: Mar 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
Thank you very much, for your answer.

I'll keep on searching, and post back any results.

regards
mik
 
Old 03-22-2012, 05:04 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,950

Rep: Reputation: 7326Reputation: 7326Reputation: 7326Reputation: 7326Reputation: 7326Reputation: 7326Reputation: 7326Reputation: 7326Reputation: 7326Reputation: 7326Reputation: 7326
you need to write a script to do that.
first locate the shell opened that terminal and than find parent process (that is the terminal emulator hopefully) and then you can send a signal to it.
remember, you cannot bring a pts to the foreground but a terminal window.

you may find this tool useful to switch:
http://tomas.styblo.name/wmctrl/

Last edited by pan64; 03-22-2012 at 05:17 AM.
 
Old 03-26-2012, 07:12 AM   #7
listmik
LQ Newbie
 
Registered: Mar 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
@pan64

if i open a terminal window (gnome-terminal) which has let's say PID 12000 and runs in let's say pts5, and then open a second one, this runs in pts6. both share the same PPID (12000). there is only one gnome-terminal process with two childs; the two instances of bash, running in different pts. so i cannot use the PID of gnome-terminal to focus a special terminal window.

... wmctrl: BINGO

AFAIK wmctrl cannot focus a window directly by either PID odr pts number, but:

setting PS1 to "\[\e]0;[\u@\h:\l \W]\\$ \a\][\u@\h:\l \W]\\$" puts the pts number of my terminalwindow in the windowtitle (...\l...), and with wmctrl -a :6 i can focus a window, which has the substring :6 (the pts number) in its title.

issue solved for me, thank you all for your replies

mik
 
Old 03-28-2012, 05:01 AM   #8
listmik
LQ Newbie
 
Registered: Mar 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
correction, just to clear things up:

... if i open a terminal window (gnome-terminal) which has let's say PID 12000 and runs in let's say pts5, and then open a second one, this runs in pts6 ...

the gnome-terminal process itself is not connected to pts5, it is the bash process, which will be automatically started by gnome-terminal, which runs in pts5.

all other statements are correct, and work for me. thanks.

mik
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find FC switch IP address jnreddy Linux - Server 2 09-15-2011 01:33 PM
[SOLVED] find command line switch value Cpare AIX 2 06-16-2011 03:44 PM
Help Please!! -- need to find command that will switch you back to your previous CWD Tron55555 Linux - General 2 05-15-2008 10:35 PM
Can't find a Cisco Switch's IP address icrangirl Linux - Newbie 2 04-28-2006 11:35 AM
Can I switch an existing Thunderbird account from POP to IMAP? pnellesen Linux - Software 4 08-24-2005 11:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration