Bash scriipt calling Konsole in Sudo Mode
All,
I'm running Kubuntu, so it is "Konsole", not "Terminal" on my box. I need a bash script that does the following:
Konsole sessions open at the start of any login on my computer. It's such a pain to have to manually do this every time I login. Ideally, for security, the command will be: Code:
bash /...path.../sudologin.sh mypass All help appreciated! Cheers! TBNK |
sounds like a lot to figure out, your side panel says you've been using Linux for at least 3 yrs now, what have you figured out so far, other then the steps of operation?
using a Konsole, or you can install a different terminal to work in so it does not kill that one while you're working on figuring out how to kill a current Konsole terminal. work out the steps in a cli then add to a script test, fix, repeat until you get it. one step at a time. somethink like this to kill kill kill the terminals Code:
ps ux | grep xfce4-terminal | xargs kill |
Quote:
Quote:
https://docs.kde.org/trunk5/en/appli...e-options.html Quote:
man sudo man sudoers man kill man pgrep man ps man killall |
Progress
Quote:
From what you are saying my script needs to say: Code:
curdir='$pwd;
Cheers! TBNK |
All,
On the Redhat and Suse flavors of Linux the cli cmd: Code:
kdesu konsole Code:
konsole -e "su -" Since I'm attempting the opening of multiple tabs, needing the ktabs.txt file, not sure where to put this command set, in the ktabs.txt file or before it? Cheers! TBNK |
It seems that other terminals are better than konsole nowadays. But with konsole,
Code:
#!/bin/sh |
Code
All,
The code I currently have is Bash Script: Code:
#! /bin/bash Code:
#! ktabs.txt file adding this to a custom application launcher to get around this, but if you know the way to store this command set for continued execution it would be nice. Out of curiosity I'm wondering if the "nohup" background run cmd will work? Cheers! TBNK |
The -e option should be the last item on the line.
|
I ran my code, both from a launcher and from an "F2" window piping to error file and got no errors, but also the 3 knosole sessions did not apprear, so there is something wrong with the code.
Cheers! TBNK |
Quote:
Thanks! Moving the -e to the end of the line, it now executes only I'm just only getting 2 tabs and none are in the sudo mode. Cheers! TBNK |
All,
OK found the issue with the 3rd tab in the ktabs.txt file but now wondering if the sudo cmd needs to be in that file at the end of each tab line, since none of the sessions are coming up "SUDO"? Cheers! TBNK |
Here is an example:
Code:
#!/bin/sh |
Quote:
Thanks, but didn't work! Still never logs to SUDO mode! Cheers! TBNK |
Quote:
I see in some HOWTOs that it's -c for a cmd instead of -e to execute, but my system runs the -e. My question then is should the -e be in the ktabs.txt file. And should that replace the: Code:
command=/usr/bin/sudo -i /bin/sh Code:
-e sudo su -u root -p mypass I'm seeing this is one of those: "Hold your mouth just right!" situations! He He! Cheers! TBNK |
Turbocapitalist,
Would it be that my script needs to call another script the uses a for loop to find each konsole tab and execute the "sudo su -u root -p mypass" cmd on each tab? Cheers! TBNK |
Will it work?
Turbocapitalist,
In particular I found this script: Code:
for service in `qdbus | grep org.kde.konsole-`; do Code:
:1.10 "qdbus | grep org.kde.konsole" Got nothing and cmd: qdbus | grep org Gave: Code:
org.freedesktop.Notifications "qdbus | grep konsole" Opened a new terminal window in sudo mode, but not a new tab. Cheers! TBNK |
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?
|
ll,
Nothing I've tried has worked yet! Can I get some help here? TBNK |
|
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 |
Quote:
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 |
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 |
Quote:
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 Cheers! TBNK |
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. |
3 Tries
All,
OK I've written 3 scripts to try this and none of them work" Script#1 Code:
#! /bin/bash Code:
#! /bin/bash Code:
#! /bin/bash Cheers! TBNK |
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.
|
Quote:
OK! Modified Scipt #3 to: Code:
#! /bin/bash Code:
title: Konsole1;; workdir: /home/files/;; profile: default;; command=/usr/bin/sudo su -u root -p mypass 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 |
Well,
Modified ktabs.txt to: Code:
title: Konsole1;; workdir: /home/files/;; profile: default;; command=/usr/bin/sudo su -u root -p mypass Cheers! TBNK |
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.
|
Quote:
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 Code:
#!/bin/sh Code:
title: Konsole1;; workdir: /home/files/;; profile: default;; command=/usr/bin/sudo -i /bin/sh 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 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 |
What is the exact error message from running the following manually?
Code:
/usr/bin/sudo -i /bin/sh |
Quote:
Error is: Quote:
TBNK |
Quote:
|
Quote:
What am I looking for in /etc/sudoers? Cheers! TBNK |
Quote:
Code:
sudo -l Code:
sudo more /etc/sudoers |
Turbocapitalist,
I never modify this file, so don't understand why it should error. Is the error msg saying my hostname is missing or invalid? I typed in the cmd: "hostname" and the return was "(none)". But I checked the /etc/hosts file and the hostname is set to "Aspire-LT" at 127.0.1.1 Doesn't the /etc/sudoers file read this /etc/hosts file? Cheers! TBNK |
No, I don't think it does read /etc/hosts. I am somewhat sure that sudo uses the same source as the hostname utility does.
I would recommend starting a new thread about the sudo problem and then returning to this thread when that is resolved. People more familiar with sudo will see the new thread even if they have ignored this one about konsole. |
Turbocapitalist,
OK opened the new thread at: Hope I explained it right! Cheers! TBNK |
All times are GMT -5. The time now is 04:30 PM. |