LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 04-11-2007, 05:39 AM   #1
helptonewbie
Member
 
Registered: Aug 2006
Location: England Somewhere
Distribution: Mandriva, PCLinuxOS, Karoshi, Suse, Redhat, Ubuntu
Posts: 518

Rep: Reputation: 39
Question Getting bash script files to run as root user


Hello to all,
What i am trying to do is get my bash scripts to run when executed as any user. Basically all scripts are locked down to only allow root to execute them. i have used things like the kde desktop shortcut which links to the script file and i can set the kde link to run it as root and it asks me for the root password thats fine. But inside that file will be another command at some point trying to execute the next bash script i want run. This is where the problem is, it doesn't run that command and thats what i need to happen. I've even tried it using the "kdesu" command which is basically the same thing as the desktop link shortcut method. Which does the same problem. Also if the script is run and i set the "kdesu" inside the file that was run to see if it even prompts me for a password to then run the next script it doesn't do that.

So why does my script run yet not execute the next bash script i want it to.
And
How can i get it to do this.

Thanks for any help
Mark

PS- i've even tried sudoers but even after putting the username into the sudoers file it still didn't work and said username isn't in sudoers file.

Last edited by helptonewbie; 04-11-2007 at 05:40 AM.
 
Old 04-11-2007, 06:16 AM   #2
omnio
Member
 
Registered: Feb 2007
Location: $HOME
Distribution: Hardened Gentoo
Posts: 66
Blog Entries: 1

Rep: Reputation: 16
If I understood right, you have a chain of scripts. Inside a script, how do you call the next script, sourcing it or executing it? If you just execute it, what about sourcing? For example:

Executing:
Code:
#!/bin/bash
# script1

.....
./script2
.....
Sourcing:
Code:
#!/bin/bash
# script1

.....
source script2
.....
 
Old 04-11-2007, 06:39 AM   #3
helptonewbie
Member
 
Registered: Aug 2006
Location: England Somewhere
Distribution: Mandriva, PCLinuxOS, Karoshi, Suse, Redhat, Ubuntu
Posts: 518

Original Poster
Rep: Reputation: 39
thanks for the reply, it needs to execute the next script, it would be better any way. As one script executes the next script then the next script executes another script and so on. i can get the first script i execute to run fine as root, but it doesn't execute the command from within that same script which would run the next script that i also want run as root.

i tried the source thing to and that didn't work, again it ran fine when i execute the command from just the normal bash after su'ing to root. But when the same command is run from within the executed script its like it just scripts that command but it still runs the rest???

Cheers for your reply
 
Old 04-12-2007, 11:49 AM   #4
cfaj
Member
 
Registered: Dec 2003
Location: Toronto, Canada
Distribution: Mint, Mandriva
Posts: 221

Rep: Reputation: 31
Quote:
Originally Posted by helptonewbie
Hello to all,
What i am trying to do is get my bash scripts to run when executed as any user.
...
So why does my script run yet not execute the next bash script i want it to.
And
How can i get it to do this.
...

PS- i've even tried sudoers but even after putting the username into the sudoers file it still didn't work and said username isn't in sudoers file.

If "said username isn't in sudoers file", you didn't put it there. Did you use visudo to edit the sudoers file? What did you put in the file?

 
Old 04-13-2007, 04:06 AM   #5
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,287

Rep: Reputation: 173Reputation: 173
what are you trying to achieve exactly?

there's maybe a better way to do it.
 
Old 04-13-2007, 09:09 PM   #6
helptonewbie
Member
 
Registered: Aug 2006
Location: England Somewhere
Distribution: Mandriva, PCLinuxOS, Karoshi, Suse, Redhat, Ubuntu
Posts: 518

Original Poster
Rep: Reputation: 39
Talking

Quote:
Originally Posted by cfaj

If "said username isn't in sudoers file", you didn't put it there. Did you use visudo to edit the sudoers file? What did you put in the file?

Er nope just edited the main sudoers file, put my username in it and all all, exactly how it was for root wrong i take it :P

--------------
Quote:
what are you trying to achieve exactly?

there's maybe a better way to do it.

I've written a program basically and i've written it basically with root accessing all the commands and so on inside it. Of course not wanting to run the program when i run it and logging in as root or 'su' to root, i want to do it by clicking icon, and the thing runs as any user as root as long as they know the root password. OBVIOUSLY only the right people have the root password

Thanks for the replies peeps
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Root user check in bash script doesn't work tawalker Programming 6 12-18-2011 03:06 AM
How do I run a startup script as a user other than root? Questor21 Linux - Software 4 04-08-2006 11:51 AM
How to run startup script/daemon as a user other than root? Akhran Debian 2 02-04-2006 01:20 AM
Bash script to email setuid root files deoren LinuxQuestions.org Member Success Stories 1 01-30-2005 09:56 AM
how do I make sure that the user that is going to run the script is a root user??? nikold01 Linux - General 3 09-10-2004 07:54 AM


All times are GMT -5. The time now is 07:41 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration