ssh to multiple servers in seperate tabs in Konsole with one?bookmark or script?

JW jw at mailsw.com
Sat Aug 9 22:42:49 BST 2008


On Wednesday 06 August 2008 20:14:07 Stephen Dowdy wrote:
> JW wrote, On 08/06/2008 05:47 PM:
>
> JW,
>
> fwiw, here's a framework (no error checking, buggy) based upon the
> scripts i sent out earlier for a scripted "Mega Konsole" that i think
> does what you want. 

> .  (i *think* your issue about having to 
> send-all a password to 'su'/'sudo' should work if you do it right
> and don't use the while-loop list of commands to exec.)
>
> --stephen

Hi Stephen,

I modified your script a little bit, it does seem like it's going to work.

I'm able to use sudo / su with "send input to all sessions" just fine.

It seems to trip over itself a little bit, at first I was getting errors like 
this:

> ./konssh3
call failed
call failed
call failed
Uh oh.. can't write data..
true
./konssh3: line 43: syntax error: unexpected end of file

> ./konssh3
Uh oh.. can't write data..
Uh oh.. can't write data..
true
./konssh3: line 43: syntax error: unexpected end of file



In addition to those errors it would randomly work or fail to open a tab with 
any given host - sometimes I'd end up with several tabs - or a few, or only 
one. I made a guess that it was moving too fast for its own good, slowed it 
down with a few sleep statements and it nows seems to be working good.

I removed the --nomenubar option since it bothered me for some reason.

I commented out the while loop because it was causing this error:

./konssh3: line 47: syntax error: unexpected end of file

Also I don't understand the line about "You can now do things like:
dcop ${KID} konsole sendAllSessions "shutdown -h now" " It doesn't work to run 
that in the initiating console. (I tried using ls /etc instead of 
shutdown :-) )

I added the -A option to the ssh client.

So now I have this (If you strip out the comments it's pretty short!):


#!/bin/sh
# Title: mega-konssh
# Description: create a scriptable konsole with many session tabs
# Author: Stephen Dowdy (sdowdy at ucar.edu)
# Caveats:  work-in-progress

host_list="root at host1 root at host2 root at host3 joe at host4 mary at host5"

# Create the MainWindow....
konsole \
    --script \
    --caption "My Sessions" \
    --T "My Sessions" \
    --vt_sz 132x42 \
    --noclose \
    &
KID="konsole-$!"
#    --nomenubar \

sleep 1.5s;

for session in ${host_list}; do
  sid=$(dcop ${KID} konsole newSession)
  dcop ${KID} ${sid} renameSession "${session}"
  sleep 0.5s
  dcop ${KID} ${sid} sendSession "ssh -A $session"
done

sleep 1s;
# close the now useless first session
dcop ${KID} session-1 closeSession

#dcop ${KID} konsole sendAllSessions "echo 'Hello World'"

# Run our list of commands across all session tabs
# while read command; do
#  dcop ${KID} konsole sendAllSessions ${command}
#<<"EOF"
#uptime
#echo "done"
#EOF

#echo "You can now do things like:"
#echo 'dcop ${KID} konsole sendAllSessions "ls /tmp"'

exit 0
___________________________________________________
This message is from the kde mailing list.
Account management:  https://mail.kde.org/mailman/listinfo/kde.
Archives: http://lists.kde.org/.
More info: http://www.kde.org/faq.html.




More information about the kde mailing list