Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

trying to generate a terminal tab (or window) for each process ...

47 views
Skip to first unread message

qwert...@syberianoutpost.ru

unread,
Oct 25, 2012, 6:33:17 PM10/25/12
to
I have some bash script that starts a number of python programs, a la:
~
for l in $(ls *.py); do
( python $l & );
done
~
the thing is that each program generates some output and if you sun it this
way all the output will show up on the same screen, so, I would like to have
each of the processes in its own terminal tab (or window) of an already open
(or to be opened) bash shell
~
What am I missing in that piece of code?
~
thanks
lbrtchx
comp.unix.shell: trying to generate a terminal tab (or window) for each
process ...

Chris F.A. Johnson

unread,
Oct 25, 2012, 6:41:26 PM10/25/12
to
On 2012-10-25, qwert...@syberianoutpost.ru wrote:
> I have some bash script that starts a number of python programs, a la:
> ~
> for l in $(ls *.py); do

Not only is ls unnecessary, but it will break your script if any filenames
contain whitespace or other pathological characters. Use parameter expansion
directly:

for l in *.py


> ( python $l & );
> done
> ~
> the thing is that each program generates some output and if you sun it this
> way all the output will show up on the same screen, so, I would like to have
> each of the processes in its own terminal tab (or window) of an already open
> (or to be opened) bash shell
> ~
> What am I missing in that piece of code?

xterm -e python "$1" &

--
Chris F.A. Johnson, author <http://shell.cfajohnson.com/>
===================================================================
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)

qwert...@syberianoutpost.ru

unread,
Oct 26, 2012, 6:29:24 PM10/26/12
to
~
> xterm -e python "$1" &
~
it worked, but it opened different windows for each of the processes
~
How do you open all windows as added tabs of the window from which you started
all other processes?
~
thanks
lbrtchx

Chris F.A. Johnson

unread,
Oct 26, 2012, 7:52:49 PM10/26/12
to
What does the man page for your terminal say?

(Not all terminals have tabs.)

qwert...@syberianoutpost.ru

unread,
Oct 27, 2012, 10:11:09 AM10/27/12
to
~
> > How do you open all windows as added tabs of the window from which you
started
> > all other processes?

> What does the man page for your terminal say?

> (Not all terminals have tabs.)
~
OK, I will have to live with that. Yet, knoppix 7.0.2 uses lxterminal, which
lets you edit text in it, but I still haven't figured out how to start them as
part of the same lxterminal window
~
$ lxterminal --help
Usage:
lxterminal [Options...] - LXTerminal is a terminal emulator

Options:
-e, --command=STRING Execute the argument to this option inside
the terminal
--geometry=COLUMNSxROWS Set the terminal's size
-l, --loginshell Execute login shell
-t, -T, --title=STRING Set the terminal's title
--working-directory=DIRECTORY Set the terminal's working directory
~
lbrtchx

Chris F.A. Johnson

unread,
Oct 27, 2012, 3:10:08 PM10/27/12
to
On 2012-10-27, qwert...@syberianoutpost.ru wrote:
> ~
>> > How do you open all windows as added tabs of the window from which you
> started
>> > all other processes?
>
>> What does the man page for your terminal say?
>
>> (Not all terminals have tabs.)
> ~
> OK, I will have to live with that. Yet, knoppix 7.0.2 uses lxterminal, which
> lets you edit text in it, but I still haven't figured out how to start them as
> part of the same lxterminal window

Nothing prevents you from using a terminal that does have tabs, e.g. konsole
or mrxvt, though I don't know whether they can create tabs from a script.

Jim Diamond

unread,
Oct 28, 2012, 9:16:51 PM10/28/12
to
On 2012-10-27 at 16:10 ADT, Chris F.A. Johnson <cfajo...@gmail.com> wrote:
> On 2012-10-27, qwert...@syberianoutpost.ru wrote:
>> ~
>>> > How do you open all windows as added tabs of the window from which you
>> started
>>> > all other processes?
>>
>>> What does the man page for your terminal say?
>>
>>> (Not all terminals have tabs.)
>> ~
>> OK, I will have to live with that. Yet, knoppix 7.0.2 uses lxterminal, which
>> lets you edit text in it, but I still haven't figured out how to start them as
>> part of the same lxterminal window
>
> Nothing prevents you from using a terminal that does have tabs,
> e.g. konsole or mrxvt, though I don't know whether they can
> create tabs from a script.

You can certainly use something like xdotool to send the "create new
tab" keycode to urxvt (and I'd guess this would work for mrxvt and
konsole as well), but whether you can do something less roundabout, I
don't know.

In urxvt the tabs are handled by the perl extension, and I would think
you should be able to do it, but I find the interface to the perl
extension stuff a bit confusing.

Cheers.
Jim
0 new messages