Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
run script with root permision
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
d0minus
Tux's lil' helper
Tux's lil' helper


Joined: 25 Apr 2005
Posts: 90
Location: Ukraine

PostPosted: Fri Mar 03, 2006 10:55 am    Post subject: run script with root permision Reply with quote

on boot my system run script with root permision but only once
after that it run with user permision. How I can run this script from root?
Code:

#!/bin/bash
while (sleep 5)
do
    RESULT3=`ps ax|grep new|grep print`;
    if [ "$RESULT3" == "" ]
        then
            cp /home/user/.Xauthority /root/.Xauthority
            su -c "DISPLAY=:0 /usr/share/print/new_print > /dev/null &" user;
    fi
done

I think su must read root password from file. But how to do this?
Back to top
View user's profile Send private message
chrism
Guru
Guru


Joined: 15 Jul 2004
Posts: 526

PostPosted: Fri Mar 03, 2006 11:02 am    Post subject: Reply with quote

su -c "what ever you what to execute"

make shure your user is in the wheel group.

Chris
Back to top
View user's profile Send private message
d0minus
Tux's lil' helper
Tux's lil' helper


Joined: 25 Apr 2005
Posts: 90
Location: Ukraine

PostPosted: Fri Mar 03, 2006 11:17 am    Post subject: Reply with quote

su -c "what ever you what to execute" in such case it ask a root password
user is in wheel group
Back to top
View user's profile Send private message
JeliJami
Veteran
Veteran


Joined: 17 Jan 2006
Posts: 1086
Location: Belgium

PostPosted: Fri Mar 03, 2006 12:11 pm    Post subject: Reply with quote

sounds like a job for sudo
_________________
Unanswered Post Initiative | Search | FAQ
Former username: davjel
Back to top
View user's profile Send private message
d0minus
Tux's lil' helper
Tux's lil' helper


Joined: 25 Apr 2005
Posts: 90
Location: Ukraine

PostPosted: Fri Mar 03, 2006 12:30 pm    Post subject: Reply with quote

davjel
you are wright but I cannot execute it from bash :(
for example
Code:
sudo "DISPLAY=:0 xcalc"

sudo: DISPLAY=:0 xcalc: command not found


what I does wrong?
Back to top
View user's profile Send private message
JeliJami
Veteran
Veteran


Joined: 17 Jan 2006
Posts: 1086
Location: Belgium

PostPosted: Fri Mar 03, 2006 12:38 pm    Post subject: Reply with quote

if you have env_keep=DISPLAY on for your sudo user you can just start xcalc:
Code:
$ sudo xcalc

from within an xterm
_________________
Unanswered Post Initiative | Search | FAQ
Former username: davjel
Back to top
View user's profile Send private message
d0minus
Tux's lil' helper
Tux's lil' helper


Joined: 25 Apr 2005
Posts: 90
Location: Ukraine

PostPosted: Fri Mar 03, 2006 1:38 pm    Post subject: Reply with quote

plz write more detail how to set env_keep=DISPLAY
tnx
Back to top
View user's profile Send private message
JeliJami
Veteran
Veteran


Joined: 17 Jan 2006
Posts: 1086
Location: Belgium

PostPosted: Fri Mar 03, 2006 4:36 pm    Post subject: Reply with quote

this is part of my sudoers file (edit with visudo!):
Code:
# Allow users in group users to export specific variables
Defaults:%users env_keep=DISPLAY

_________________
Unanswered Post Initiative | Search | FAQ
Former username: davjel
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum