Skip to main content

Thread: Sending commands to another Terminal/Configuring bash env remotely


hello,

i'm new please inform me if break form of etiquette first post here; i'll take note of future. hope i'm posting in correct place.
similar post i've found on here: http://ubuntuforums.org/showthread.php?t=1571708
doesn't address i'm looking for.

the problem:
how instruct command executed on specified terminal/shell terminal/shell.
------
example:
tty1:
# script_that_sends_command "ls"

tty2:
*displays current directory contents of tty2*
-------

note: doing
ls > /dev/tty2 or ls | tee /dev/tty2
display current directory contents of tty1 on tty2, not i'm looking do.

what want for:
it's not uncommon me have 10 terminals open. if change in 1 terminal, such few exported environment variables in script, have manually run script on each terminal change global. beyond awesome if make script detects open terminals , tells them run other script update environment variables. can't figure out how update variables, or run commands, on existing shells/terminals without typing in every single window. solution can figure create kind of custom background process gets launched per new shell , listens process tell run designated script. perhaps there's simpler way..

i'm not sure if should using word "terminal" here either...maybe want send command bash shell running on terminal device?

insight have appreciated, "it can't done." gotta know if there's way! =)

welcome forums!

know how accomplish using terminals administrated 'screen'. example if have 2 gnome-terminals running:
code:
$ w  18:31:58 10:37,  3 users,  load average: 1.03, 0.79, 0.60 user     tty                   login@   idle   jcpu   pcpu user    tty7     :0               07:55   10:36m 31:24   0.40s gnome-session user    pts/0    :0.0             07:56    0.00s  0.27s  0.01s w user    pts/1    :0.0             18:25   11.00s  0.24s  0.24s bash
then go first 1 , enter:
code:
$ screen -s mysession1
now terminal accessible using screen name 'mysession1'.

change directories in session can see trick working:
code:
$ cd music
go second terminal , enter:
code:
$ screen -s mysession1 -x stuff "ls ^m"
you sending request execute 'ls 'to first terminal. ^m representation of escaped control+m (i.e. 'enter'). escape control character in bash press control+v. achieve desired results have press control+v control+m.

hope helps,
regards.

note 1: if screen not installed, install this:
code:
$ sudo apt-get install screen
note 2: here's couple of threads can helpful: this , this.


Forum The Ubuntu Forum Community Ubuntu Specialised Support Ubuntu Servers, Cloud and Juju Server Platforms [SOLVED] Sending commands to another Terminal/Configuring bash env remotely


Ubuntu

Comments

Popular posts from this blog

Warning, the Safe Path is not accessible vm3 - Joomla! Forum - community, help and support

uppercase letters in url - Joomla! Forum - community, help and support

Joomla! Update is not offering Joomla 3 - Joomla! Forum - community, help and support