This forum has been archived. All content is frozen. Please use KDE Discuss instead.

CLI Konsole -p Command query

Tags: None
(comma "," separated)
sfitcs
Registered Member
Posts
7
Karma
0

CLI Konsole -p Command query

Thu Feb 27, 2014 1:07 pm
I want to start an ssh screen session in Konsole from a script
(/etc/rc.local) run on the machine I want to connect to. e.g.:-
Box A boots and runs rc.local that then uses an ssh command to start a
konsole session, for which there is no previously defined profile, on
Box B that connects to Box A.

This works fine when I'm calling a previously defined profile on Box
B. e.g.:-
;the script on box A (/etc/rc.local):-
Code: Select all
ssh scott@vbserver 'export DISPLAY=:0 && konsole --profile dev'


;the konsole profile on box B e.g.:-
(/home/scott/.kde/share/apps/konsole/dev.profile):-
Code: Select all
[Appearance]
ColorScheme=BlackOnLightYellow
Font=Oxygen Mono,12,-1,5,50,0,0,0,0,0
[General]
Command=ssh -t dev screen -dR
Directory=
Icon=network-server
LocalTabTitleFormat=%D : %n
MenuIndex=3
Name=Dev
Parent=FALLBACK/
RemoteTabTitleFormat=Dev : %u
ShowNewAndCloseTabButtons=false
ShowTerminalSizeHint=false
StartInCurrentSessionDir=false


I've tried various CLI options using both the "-p Command=" and "-c
<command>
" without success. Box A has the SSH key copied to it, and is
listed in known_hosts on Box B. e.g.:-
/etc/rc.local (Box A):-
Code: Select all
ssh scott@vbserver 'export DISPLAY=:0 && konsole -p Command='ssh
scott@wheezystripped' -p Icon=network-server --new-tab'


I've also tried with only the "-p Command=" with and without the
--new-tab, as well as different orders of Konsole parameters.
Everything works fine if I don't try the command i.e. just use:-
Code: Select all
--new-tab and -p Icon=


I really don't want to resort to the :-
Box A Test for existing profile on Box B (using ssh)
Code: Select all
  If ! Exist create profile
Use profile (with ssh)



Debian 7 with backports enabled.
Qt: 4.8.2
KDE Development Platform: 4.8.4 (4.8.4)
Konsole: 2.8.4


Kind regards
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: CLI Konsole -p Command query

Fri Feb 28, 2014 8:04 am
Other than the command to execute, and icon, is there anything else special about the previously non-existent profile?


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
sfitcs
Registered Member
Posts
7
Karma
0

Re: CLI Konsole -p Command query

Fri Feb 28, 2014 8:40 am
bcooksley wrote:Other than the command to execute, and icon, is there anything else special about the previously non-existent profile?


I don't understand your question. I'm not sure how I could clarify things without repeating myself. ???
The profile doesn't exist - so I'm not sure what is special about it. If there was a profile I'd have no problems. i.e. for boxes I regularly access remotely they have something like the following example in /etc/rc.local which works fine, because it's calling an existing profile (see last command) e.g.:-
Code: Select all
ssh scott@vbserver 'export DISPLAY=:0 && kdialog --icon network-server --title "Remote Server"\
 --caption "Status" --msgbox "The Development Server is ready"' && echo "tha development server is red-e" | festival --tts'
 ssh scott@vbserver 'export DISPLAY=:0 && konsole --profile dev'
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: CLI Konsole -p Command query

Fri Feb 28, 2014 9:43 am
If you are aware of the fields in the Konsole profile which differ from system to system, you could have the rc.local script generate one and scp it to the system where Konsole will be executed prior to running Konsole.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
sfitcs
Registered Member
Posts
7
Karma
0

Re: CLI Konsole -p Command query

Fri Feb 28, 2014 12:01 pm
bcooksley wrote:If you are aware of the fields in the Konsole profile which differ from system to system,

??? They don't differ from system to system. There are no other systems (on which KDE is running). Box A could be any of hundreds of remote headless servers - for which reason I don't want to create local konsole profiles (there can be no remote konsole profiles). Box B is always my workstation - which only has one version of Konsole on it (the version noted in the OP). I apologise if that confused you.
you could have the rc.local script generate one and scp it to the system where Konsole will be executed prior to running Konsole.

I could , but, as I noted in the OP (you must of missed that):-

I really don't want to resort to the :-
Box A Test for existing profile on Box B (using ssh)
Code: Select all
If ! Exist create profile
Use profile (with ssh)

I don't want to have to do that (create hundreds of different konsole profiles). Some of these servers are only ever accessed once or twice (cloud instances).

It should be possible to call konsole and invoke the same -p profile parameters and -e commands that are available locally don't you think?
Perhaps I should just submit a bug report upstream as it's likely not a Debian problem, at the very least the documentation should be updated to reflect the failing.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: CLI Konsole -p Command query

Fri Feb 28, 2014 10:18 pm
I fail to see the problem it seems. To clarify - Konsole is always being executed on the same system, and the *same* profile, which is *exactly* the same (for all settings, including title, command, etc) is always executed irregardless of the system which is going to execute Konsole?

If so, then you should be able to simply hardcode the profile name as is, and use the -e option to temporarily override the command as needed. Be aware that the -e option likely won't invoke a shell, so you'll need to ask for it to be executed if you need to run multiple commands, one after the other.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
sfitcs
Registered Member
Posts
7
Karma
0

Re: CLI Konsole -p Command query

Fri Feb 28, 2014 11:45 pm
bcooksley wrote:I fail to see the problem it seems.

Yes. :)

To clarify - Konsole is always being executed on the same system,


Yes.

and the *same* profile,


No.

which is *exactly* the same (for all settings, including title, command, etc) is always executed irregardless of the system which is going to execute Konsole?


No (again).

If so, then you should be able to simply hardcode the profile name as is, and use the -e option to temporarily override the command as needed.


"Reusing" an existing profile means altering that profile if it's already in use - which defeats the purpose. :(
i.e. if I have an existing profile (e.g. dev - see OP) that uses a particular icon (e.g. "=network-server") and hardcodes the RemoteTabTitleFormat (e.g. "=dev : %u") and uses a Command (e.g. "=ssh -t dev screen -dR") I can "reuse" it, but every change to the existing profile parameters results in a change to any konsole sessions using that profile.

Example - this works, but it modifies any exiting Konsole instance using that profile (dev):-
Code: Select all
sysad@dev:~$ ssh scott@vbserver 'export DISPLAY=:0 && konsole --profile dev -p Command="ssh -t sf screen -dR" -p Icon=network-server-database -p RemoteTabTitleFormat="E2-sf: %u" -e beep'


Be aware that the -e option likely won't invoke a shell, so you'll need to ask for it to be executed if you need to run multiple commands, one after the other.


Yes, I'm aware of that (see OP). In those circumstances I use the -p Command="CommandToRunInShell" - but, part of the point of this thread, the -p Command=ssh $Something" doesn't seem to work when called via ssh from another box.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: CLI Konsole -p Command query

Sat Mar 01, 2014 10:17 am
I see, i've checked the Konsole code and why I can't see why what you've done above doesn't work, you should be able to substitute "-p Command=" for "-e". Please note that Command= is also affected by the same shell issues.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]


Bookmarks



Who is online

Registered users: bancha, Bing [Bot], Evergrowing, Google [Bot], lockheed, mesutakcan, Sogou [Bot]