Linux - DesktopThis forum is for the discussion of all Linux Software used in a desktop context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
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?
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.
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
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.
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;
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.
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.
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
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?
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.
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
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.