[kde-linux] Sessions names

Boyan Tabakov blade.alslayer at gmail.com
Wed Jan 17 09:31:24 UTC 2007


On 16.1.2007 21:52, wireless wrote:
> Hey,
>
> That actually works!

I am glad I could be of assistance!

> However, I have to develop this extensive list or can I just do
> something that uses a singular file? regular expressions?
>
> Specifically, I have in this dir:
> ~/.kde3.5/share/apps/konsole/
> and a separate file for each entry, I'll have hundreds of files
>
> Example: cat 192.168.2.80.desktop
> [Desktop Entry]
> Cwd=
> Exec=ssh -l  admin 192.168.2.80
> Font=
> Icon=konsole
> KeyTab=
> Name=192.168.2.67
> Schema=Linux.schema
> Term=linux
> Type=KonsoleApplication
>
>
> Any way I could have a single for a entire
> class C address? 192.168.2.*   ???

I doubt that would be possible.

> if not can I use a script to generate all the
> entries?

Yes - maybe this is what would be a good compromise.

> last, I had use this exact string:
> ssh -l  admin 192.168.2.80
>
> but what if I just wanted to:
> ssh 192.168.2.80 <as default user>   ???

What do you mean by "default user"? The default user when doing ssh is the 
username on your local machine.

Well, I suppose the normal situation will not require you to login to a device 
with more than one username. So specifying the username for each device would 
be appropriate. You can alternatively give the username in the form:

ssh admin at 192.168.2.80

> I'm not trying to be a pain, it's just I spend all day long
> sshing into targets and routers and other embedded devices
> and then the next day I do it all over again at another
> customer site.......

No problem! If there is a chance that you can do your job better and easier, 
then our efforts will be worth it.

Here is another idea that could wipe the need of hundreds of files and will be 
easier to use - e.g. no need to search your session in a list of many:

You can write a wrapper script that would start ssh to some ip and rename the 
konsole session dynamically. There are some obstacles on the way. To use a 
dcop call to konsole you need to know the pid of konsole. An example command 
is:

$ dcop konsole-<pid> session-<#session> renameSession <Session Name>

The sessions are numbered 1, 2, 3, etc. and you can easily get the current 
session with:

$ dcop konsole-<pid> konsole currentSession

The workflow as I see it is the following:
1) Start normal konsole session (your favorite shell is running inside it)
2) Open a new tab (if needed)
3) Run the wrapper script
4) Do your work

Luckily when started, a console session sets some environment variables that 
are of great assistance here: KONSOLE_DCOP_SESSION and KONSOLE_DCOP. So all 
the problems are solved with:

$ dcop $KONSOLE_DCOP_SESSION renameSession <Sessin Name>.

The only thing that is left is the way you would like to call your wrapper 
script. If you know all the ips by heart, you can do it with, let's say:

$ ssh_wrapper <ip>

Or you could create some mapping:

$ ssh_wrapper <some user friendly name>

And the wrapper script should decide which ip to ssh to.

An example script for the first scenario is something like this:


#!/bin/bash

IP=$1

dcop $KONSOLE_DCOP_SESSION renameSession $IP

ssh $IP


To set what username should be used for different ip addresses you can add 
some checks inside the script, or you could use the ~/.ssh/config file to 
specify those (see manual for ssh_config). A smarter script would also check 
if ssh or telnet should be used.

I think this would be the better way than to maintain a large list of saved 
sessions. This way you could have all logic inside one single script file and 
you can easily change anything.

I hope this will help you!

-- 
Blade hails you...

Puppet girl, your strings are mine
                       --Nightwish
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-linux/attachments/20070117/8b103a81/attachment.sig>


More information about the kde-linux mailing list