LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
LinkBack Search this Thread
Old 12-08-2011, 08:53 PM   #1
casperdaghost
Member
 
Registered: Aug 2009
Posts: 336

Rep: Reputation: 16
tmux sending commands to individual panes


So part of my job is to monitor may servers at once - check out my master plan, I am so close.
I split the terminal into twelve panes using tmux - and log into each one an tail the /var/log/messages in each pane.

hitting control -b o and typing ssh and tail -f into pane is getting tiring.

I have pushed the keys out so I can passwordless ssh to the servers.
I am just having trouble creating a script to automate my ssh logins and commands delivery - how do I issue the three commands to
each pane?

ssh casper@server1
sleep 30
tail -f /var/log/messages

each pane must ssh to a different server and tail that servers logs.

how do i issue commands to the individual panes in tmux?
Code:
#!/bin/bash
tmux split-window -v
sleep 5
tmux select-pane -t 0
tmux split-window -v
tmux select-pane -t 0
tmux split-window -v
tmux select-pane -t 0
tmux split-window -v
tmux select-pane -t 3
tmux split-window -v
tmux select-pane -t 3
tmux split-window -v
tmux select-layout even-vertical

#for ((i = 0 ; i < 5 ; i++))
for i in 0 2 4 6 8 10
do 
tmux select-pane -t $i
tmux split-window -h
done

Last edited by casperdaghost; 12-08-2011 at 08:54 PM.
 
Old 01-14-2012, 05:29 PM   #2
ThomasAdam
LQ Newbie
 
Registered: Apr 2011
Posts: 29

Rep: Reputation: 9
Use the synchronise-panes option.

-- Thomas Adam
 
Old 01-17-2012, 09:57 PM   #3
casperdaghost
Member
 
Registered: Aug 2009
Posts: 336

Original Poster
Rep: Reputation: 16
I kinda worked this out on my own.
This script will breakup the terminal into 8 seperate panes.
It sends a command to each pane via the send keys invocation.
You could just as easily send a tail -f /var/log/messages or a ssh casper@capser box or whatever.

mark my words - pretty soon you will all be using tmux - it is a productivity tool.

You have to open up a tmux session manually and then invoke the script.

Code:

#!/bin/bash

###this is going to split the pane into four 
###even horizontal panes
tmux split-window -v
sleep 1
tmux send-keys -t 0 "clear" C-m
tmux select-pane -t 0

tmux split-window -v
sleep 1
tmux select-pane -t 3

tmux split-window -v
sleep 1
tmux select-pane -t 5

tmux split-window -v
tmux select-layout even-vertical

 
###this will split each of the four panes
###vertically, resulting in eight seperate 
###panes

for i in 0 2 4 6 
do
tmux select-pane -t $i
tmux split-window -h
sleep 1
done


this goes to each pane and sends a command, in this case - just identifies the pane. 

tmux select-pane -t 0
tmux send-keys -t 0 "This is pane 0" C-m
tmux select-pane -t 1
tmux send-keys -t 1 "This is pane 1" C-m
tmux select-pane -t 2
tmux send-keys -t 2 "This is pane 2" C-m
tmux select-pane -t 3
tmux send-keys -t 3 "This is pane 3" C-m
tmux select-pane -t 4
tmux send-keys -t 4 "This is pane 4" C-m
tmux select-pane -t 5
tmux send-keys -t 5 "This is pane 5" C-m
tmux select-pane -t 6
tmux send-keys -t 6 "This is pane 6" C-m
tmux select-pane -t 7
tmux send-keys -t 7 "This is pane 7" C-m
tmux select-pane -t 8
tmux send-keys -t 8 "This is pane 8" C-m
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
tmux: Setting up panes and the programs in them by default? apt-get Linux - Software 3 01-17-2012 10:00 PM
Sending HP Printer Commands cmnorton Programming 2 12-10-2007 07:58 AM
sending at commands over pppoe? sti2envy Linux - Networking 3 10-18-2005 06:35 AM
Which files contain individual user login / logout commands andrewstr Red Hat 5 12-17-2003 05:34 PM
sending windows commands from linux dubman Linux - Networking 1 11-13-2003 07:34 PM


All times are GMT -5. The time now is 05:14 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration