LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 01-24-2020, 02:55 PM   #16
TBotNik
Member
 
Registered: May 2016
Location: Greenville, TX
Distribution: Kubuntu 18.04
Posts: 796

Original Poster
Rep: Reputation: Disabled
Will it work?


Turbocapitalist,

In particular I found this script:

Code:
for service in `qdbus | grep org.kde.konsole-`; do 
    for session in `qdbus $service | grep ^/Sessions/`; do
        qdbus $service $session org.kde.konsole.Session.runCommand "cd"
    done
done
Ran qdbus and got:
Code:
:1.10
 org.freedesktop.Notifications
:1.13
:1.2
 org.kde.klauncher
:1.3
 org.kde.kded
:1.6
 org.kde.knotify
:1.8
:1.9
 org.gtk.vfs.Daemon
org.freedesktop.DBus
Tried it with the grep filter
"qdbus | grep org.kde.konsole"
Got nothing and cmd:
qdbus | grep org
Gave:
Code:
org.freedesktop.Notifications
org.kde.klauncher
org.kde.kded
org.kde.knotify
org.gtk.vfs.Daemon
org.freedesktop.DBus
And cmd:
"qdbus | grep konsole"
Opened a new terminal window in sudo mode, but not a new tab.

Cheers!

TBNK
 
Old 01-25-2020, 01:41 AM   #17
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,312
Blog Entries: 3

Rep: Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722
Both of the examples I provided worked for me. So I am having trouble reproducing the problem you describe. Could you try summarizing it concisely with different words?
 
Old 02-07-2020, 11:37 AM   #18
TBotNik
Member
 
Registered: May 2016
Location: Greenville, TX
Distribution: Kubuntu 18.04
Posts: 796

Original Poster
Rep: Reputation: Disabled
ll,

Nothing I've tried has worked yet!

Can I get some help here?

TBNK
 
Old 02-07-2020, 11:50 AM   #19
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,312
Blog Entries: 3

Rep: Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722
I gave the solution in #6 above. Please be specific about any error messages it provides on your system.

Edit: the solution in #12 above works on more distros. Again, please be specific with the error messages.

Last edited by Turbocapitalist; 02-07-2020 at 12:27 PM.
 
Old 03-09-2020, 09:28 PM   #20
TBotNik
Member
 
Registered: May 2016
Location: Greenville, TX
Distribution: Kubuntu 18.04
Posts: 796

Original Poster
Rep: Reputation: Disabled
Help Please

All;

No matter how I try to get this to work, none of the konsole sessions ever login to the SUDO mode!

Sure could use some more ideas, since none of the suggestions posted have worked!

Cheers!

TBNK
 
Old 03-09-2020, 09:32 PM   #21
TBotNik
Member
 
Registered: May 2016
Location: Greenville, TX
Distribution: Kubuntu 18.04
Posts: 796

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Turbocapitalist View Post
Both of the examples I provided worked for me. So I am having trouble reproducing the problem you describe. Could you try summarizing it concisely with different words?
Turbocapitalist,

Sorry! No other words to describe it, it or none of the suggestions have worked! This does not produce errors, but wondering is there is a system log that might show at least something, so I know why it's not working.

Cheers!

TBNK
 
Old 03-10-2020, 01:02 AM   #22
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,312
Blog Entries: 3

Rep: Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722
What happens when you use the example in #12 above, but add in the following as the second line of the script?

Code:
set -e -v -x
It should show each line of the script before it is executing, including variable contents, but quit on the first error it encounters.
 
Old 03-10-2020, 11:45 AM   #23
TBotNik
Member
 
Registered: May 2016
Location: Greenville, TX
Distribution: Kubuntu 18.04
Posts: 796

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Turbocapitalist View Post
What happens when you use the example in #12 above, but add in the following as the second line of the script?

Code:
set -e -v -x
It should show each line of the script before it is executing, including variable contents, but quit on the first error it encounters.
Turbocapitalist,

Your script creates the 4 konsole sessions you described but nonoe are SDUO mode which will show with the /root in the dir prompt.

I captured your script and changed it for the 3 I was defining and here's it's code:
Code:
#! /bin/bash
# Script to open 3 Konsole sessions logged into SUDO mode
#
# CMD: bash /Scripts/Extras/kslog.sh
#
# Must be run in the SYDO mode! Also must be run from the App Launcher!

# Get the current dir to enable return to it
curdir=$pwd;
cd "/Scripts/Extras/";


t=$(tempfile ktabs.XXXXX) || exit 1

cat <<EOT > ${t}
title: Konsole%n;; workdir: /home/files;; profile: default;; command=/usr/bin/sudo -i /bin/sh
title: Konsole%n;; workdir: /home/files/Dropbox;; profile: default;; command=/usr/bin/sudo -i /bin/sh
title: Konsole%n;; workdir: /Scripts; profile: default;; command=/usr/bin/sudo -i /bin/sh
EOT

pkill -x konsole
konsole --tabs-from-file ${t}
sleep 1
rm -f ${t}
cd $curdir;
exit 0
Where do I insert your currently suggested line?

Cheers!

TBNK
 
Old 03-10-2020, 12:03 PM   #24
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,312
Blog Entries: 3

Rep: Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722
Insert it as the second line below the shebang. If you run the script manually from the shell, the added line will display each line of the script before it executes.

Then, as for sudo, take a look at each tab's invocation in there. In the script in the preceding post (#23) that would be lines 16 through 18 and you will see that sudo really is invoked. It is not invoked for the whole konsole program, that would be stupid as it is a graphical program. Instead sudo is invoked separately for each tab.
 
Old 04-01-2020, 09:11 PM   #25
TBotNik
Member
 
Registered: May 2016
Location: Greenville, TX
Distribution: Kubuntu 18.04
Posts: 796

Original Poster
Rep: Reputation: Disabled
3 Tries

All,

OK I've written 3 scripts to try this and none of them work"

Script#1
Code:
#! /bin/bash
# Script to login to SUDO mode on all open tabs
# CMD: bash /Scripts/Extras/logsudo.sh

# Get the current dir to enable return to it
curdir=$pwd;
cd "/Scripts/Extras/";

konsole --tabs-from-file ktabs.txt -e "su -u root -p nomened.1497"
# Return to the starting dir
cd $curdir;
Script#2
Code:
#! /bin/bash
# Script to login all tabs in SUDO mode
# CMD: bash /Scripts/Extras/sudologin.sh

# Get the current dir to enable return to it
curdir=$pwd;
cd "/Scripts/Extras/";
# kill the current konsole sessions
pkill konsole;

konsole --tabs-from-file ktabs.txt -e command=/usr/bin/sudo su -u root -p nomened.1497
set -xv;

# konsole --tabs-from-file ktabs.sh
# Return to the starting dir
cd $curdir;
Script#3
Code:
#! /bin/bash
# Script to login all tabs in SUDO mode
# CMD: bash /Scripts/Extras/tmpslogin.sh


t=$("
title: Konsole1;; workdir: /home/files/;; profile: default;; command=/usr/bin/sudo -i /bin/sh
title: Konsole2;; workdir: /home/files/Dropbox/;; profile: default;; command=/usr/bin/sudo -i /bin/sh
title: Konsole3;; workdir: /Scripts/;; profile: default;; command=/usr/bin/sudo -i /bin/sh
")

pkill konsole

konsole --tabs-from-file ${t}
set -xv
sleep 1

exit 0

# title: %n;; workdir: /tmp/;; profile: default;; command=/usr/bin/sudo -i /bin/sh
I also tried putting the "set -xv" right after the pkill konsole cmd line, but that does not work either. There are no errors produce, so no idea what is wrong.

Cheers!

TBNK
 
Old 04-01-2020, 09:26 PM   #26
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,312
Blog Entries: 3

Rep: Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722
In your post above, script #3 is the closest to working. Export the contents of ${t} into a file and then point the --tabs-from-file at that file. Note the use of a temporary file there in post #12 above. The --tabs-from-file only works with an actual file.
 
Old 04-02-2020, 12:01 AM   #27
TBotNik
Member
 
Registered: May 2016
Location: Greenville, TX
Distribution: Kubuntu 18.04
Posts: 796

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Turbocapitalist View Post
In your post above, script #3 is the closest to working. Export the contents of ${t} into a file and then point the --tabs-from-file at that file. Note the use of a temporary file there in post #12 above. The --tabs-from-file only works with an actual file.
Turbocapitalist,

OK! Modified Scipt #3 to:

Code:
#! /bin/bash
# Script to login all tabs in SUDO mode
# CMD: bash /Scripts/Extras/tmpslogin.sh


# t=$("
# title: Konsole1;; workdir: /home/files/;; profile: default;; command=/usr/bin/sudo -# i /bin/sh
# title: Konsole2;; workdir: /home/files/Dropbox/;; profile: default;; command=/usr/
# bin/sudo -i /bin/sh
# title: Konsole3;; workdir: /Scripts/;; profile: default;; command=/usr/bin/sudo -i /# bin/sh
# ")

pkill konsole
curdir=$pwd;
cd "/Scripts/Extras/";

konsole --tabs-from-file ktabs.txt
# konsole --tabs-from-file ${t}
set -exv
sleep 1

# Return to the starting dir
cd $curdir;
exit 0

# title: %n;; workdir: /tmp/;; profile: default;; command=/usr/bin/sudo -i /bin/sh
and file ktabs.txt contains:

Code:
title: Konsole1;; workdir: /home/files/;; profile: default;; command=/usr/bin/sudo su -u root -p mypass
title: Konsole2;; workdir: /home/files/Dropbox/;; profile: default;; command=/usr/bin/sudo su -u root -p mypass
title: Konsole3;; workdir: /Scripts/;; profile: default;; command=/usr/bin/sudo su -u root -p mypass
but the only action is the actual opening of konsole with the correct title and working dir, but not sudo mode.

I'm thinking something needs to be added to the ktabs.txt file to make it go sudo! Am I right? do I need to add the "set -exv" line after each konsole def line in that file?

Cheers!

TBNK

Last edited by TBotNik; 04-02-2020 at 12:07 AM.
 
Old 04-02-2020, 12:13 AM   #28
TBotNik
Member
 
Registered: May 2016
Location: Greenville, TX
Distribution: Kubuntu 18.04
Posts: 796

Original Poster
Rep: Reputation: Disabled
Well,

Modified ktabs.txt to:

Code:
title: Konsole1;; workdir: /home/files/;; profile: default;; command=/usr/bin/sudo su -u root -p mypass
set -exv
title: Konsole2;; workdir: /home/files/Dropbox/;; profile: default;; command=/usr/bin/sudo su -u root -p mypass
set -exv
title: Konsole3;; workdir: /Scripts/;; profile: default;; command=/usr/bin/sudo su -u root -p mypass
set -exv
No change in operation. Still opens the 3 konsole sessions in the normal, not sudo mode!

Cheers!

TBNK
 
Old 04-02-2020, 12:40 AM   #29
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,312
Blog Entries: 3

Rep: Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722
Please try the recipe shown in #12 verbatim. If it works, then make one change at a time. There are too many changes happening at the same time to make it easy to walk through this.
 
Old 04-03-2020, 01:57 PM   #30
TBotNik
Member
 
Registered: May 2016
Location: Greenville, TX
Distribution: Kubuntu 18.04
Posts: 796

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Turbocapitalist View Post
Please try the recipe shown in #12 verbatim. If it works, then make one change at a time. There are too many changes happening at the same time to make it easy to walk through this.
Turbocapitalist,

I've told you at least 3 times the solution in #12 does not work!

To make sure here is the script directly from your code:

Code:
#!/bin/sh
# Script to login all tabs in SUDO mode
# CMD: bash /Scripts/Extras/newslogin.sh

curdir=$pwd;
cd "/Scripts/Extras/";

t=$(tempfile ktabs.XXXXX) || exit 1

cat <<EOT > ${t}
title: Konsole1;; workdir: /home/files/;; profile: default;; command=/usr/bin/sudo -i /bin/sh
title: Konsole2;; workdir: /home/files/Dropbox/;; profile: default;; command=/usr/bin/sudo -i /bin/sh
title: Konsole3;; workdir: /Scripts/;; profile: default;; command=/usr/bin/sudo -i /bin/sh
EOT

pkill -x konsole
set -exv
konsole --tabs-from-file ${t}

sleep 1

rm -f ${t}
# Return to the starting dir
cd $curdir;

exit 0
Then modified it to:

Code:
#!/bin/sh
# Script to login all tabs in SUDO mode
# CMD: bash /Scripts/Extras/newslogin.sh

curdir=$pwd;
cd "/Scripts/Extras/";

t="ktabs.txt";
# t=$(tempfile ktabs.XXXXX) || exit 1

# cat <<EOT > ${t}
# title: Konsole1;; workdir: /home/files/;; profile: default;; command=/usr/bin/sudo -i /bin/sh
# tile: Konsole2;; workdir: /home/files/Dropbox/;; profile: default;; command=/usr/bin/sudo -i /bin/sh
# title: Konsole3;; workdir: /Scripts/;; profile: default;; command=/usr/bin/sudo -i /bin/sh
# EOT

pkill -x konsole
set -exv
konsole --tabs-from-file ${t}

sleep 1

#rm -f ${t}
# Return to the starting dir
cd $curdir;

exit 0
Even change3d the "ktabs.txt" to:

Code:
title: Konsole1;; workdir: /home/files/;; profile: default;; command=/usr/bin/sudo -i /bin/sh
title: Konsole2;; workdir: /home/files/Dropbox/;; profile: default;; command=/usr/bin/sudo -i /bin/sh
title: Konsole3;; workdir: /Scripts/;; profile: default;; command=/usr/bin/sudo -i /bin/sh

# title: Konsole1;; workdir: /home/files/;; profile: default;; command=/usr/bin/sudo su -u root -p nomened.1497
# set -exv
# title: Konsole2;; workdir: /home/files/Dropbox/;; profile: default;; command=/usr/bin/sudo su -u root -p nomened.1497
# set -exv
# title: Konsole3;; workdir: /Scripts/;; profile: default;; command=/usr/bin/sudo su -u root -p nomened.1497
# set -exv
Added only the directory control and the "set -exv" you recommended.

None of that works except to the point of opening the 3 konsole sessions in the "normal" mode, but not "sudo" mode.

I suspected that the "sudo su" cmd was not where you think it is so entered cmd:

Code:
cd /usr/bin/sudo
And got the msg: "cd: /usr/bin/sudo: Not a directory", but it is in the /usr/bin dir. However the cmd: "command=/usr/bin/sudo -i /bin/sh" is not properly executing so something different is needed that is why I had tried:"command=/usr/bin/sudo su -u root -p mypass"! That changed nothing so I ran that cmd directly and got the error: "sudo: unable to resolve host (none)".

That cmd has to work directly from the cmdline, so need to be able to fix that and then I think it will work!

Cheers!

TBNK

PS
Oh! Running the cmd: "/usr/bin/sudo -i /bin/sh" @ the cmdline yields:

##########################################################
sudo: unable to resolve host (none)
#
##########################################################

with the "#" prompt and not knowing what to enter, only "crtl+D" exits at that point. Entering the password does not actually allow entrance into the sudo mode.

man sudo show that -l not -i is a legit option for the sudo cmd; but does not produce anything usable either.

TBNK

Last edited by TBotNik; 04-03-2020 at 02:51 PM.
 
  


Reply

Tags
bash, konsole



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
vfork - suspends the calling process or the calling thread? zmau Linux - Software 3 04-21-2015 02:38 PM
LXer: The Ultimate Sudo FAQ — To Sudo Or Not To Sudo? LXer Syndicated Linux News 13 04-13-2013 01:36 AM
Konsole always give SuperUser Konsole - can't get regular shell checkmate3001 Linux - Desktop 3 08-05-2008 10:00 AM
konsole acts as "Root Konsole" ab44045 Linux - General 11 06-11-2007 05:18 PM
odd recursion: calling "by hand" vs calling by cronscript... prx Programming 4 02-12-2005 04:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 11:52 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration