Re: [kde-linux] Sessions names



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@xxxxxxxxxxxx

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

Attachment: pgpDJikzuGIKM.pgp
Description: PGP signature

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

Relevant Pages

  • Re: [kde-linux] Starting ssh at log-in
    ... it sounds to me that a saved konsole session (I mean a session ... Save the session and then in ~/.kde/Autostart add the following script: ... paste and up-arrow on the command line didn't work in it either. ...
    (KDE)
  • Re: put ssh tunnel in background with expect
    ... the exp-background call sucks up output from that session (that ... the next spawn creates an ssh connection to the final host via ... of the first ssh session would serve its purpose. ... My expect script works if I don't use the forking business, ...
    (comp.lang.tcl)
  • ksh script to issue multiple commands over ssh and parse output of each response
    ... With the following script I am trying to issue 3 commands over 1 SSH ... session as an example of a larger problem I'm working on. ... is how to isolate the answers of each command when the result is ...
    (comp.unix.shell)
  • Re: stupid IE7 question
    ... closer look on session handling. ... Obscure methods like hiding an URI always ... rewrites itself to another script of yours with the session key as the ... I am currently testing a proprietary secure web based ...
    (Pen-Test)
  • Re: (Sloppy correction) Re: session management with database: optimal parameters in php.ini
    ... looking then another script read N! ... make it so simple that there are obviously no deficiencies, ... but I never used their db session management ... I avoid MySQL since I consider it an inferior db. ...
    (alt.php)