Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
 
Reply to this topicStart new topic
> Startup Scripts And Su
jdklusman
post Mar 4 2004, 02:49 AM
Post #1


Whats this Lie-nix Thing?
*

Group: Members
Posts: 7
Joined: 19-June 03
Member No.: 986



Im writing a start-up script that trys to su to a non superuser account to start a screen for a program (mutella) and then detaches the screen. Im running into trouble. Heres my code for it that is relevant to the issue.

M_USER="jd"
DIR=/usr/local/bin

PATH=/bin:/usr/bin:/sbin:/usr/sbin
DAEMON=$DIR/mutella
NAME=Mutella
DESC="P2P Client"
case "$1" in
start)
if [ -e $DIR ];
then
echo "Starting $DESC: $NAME"
cd $DIR
su $M_USER -c `screen -d -m -S $NAME $DAEMON`
else echo "No such directory: $DIR"
fi
;;
esac
exit 0

When i execute this Mutella starts fine, but i can not reattach the screen as root (because the screen belongs to JD account) and when i su to JD and issue the screen -R or even screen -r Mutella it tells me im not the owner of the screen.

Any help would be gratefull, also been searching for a site dedicated to coding linux scripts any links?
Go to the top of the page
 
+Quote Post
hughesjr
post Mar 4 2004, 08:33 AM
Post #2


Its GNU/Linuxhelp.net
*******

Group: Admin
Posts: 3,433
Joined: 25-July 03
From: Corpus Chrsiti, TX, USA
Member No.: 1,151



In a bash / sh script .... the things surrounded by `` execute at the command line and then return the results to the script ... I think you want to use " or ' instead of ` for the script.

Second thing is that if you want to get all the environment variables for the user jd, you need to use :

su - jd -c "commands"

instead of:

su jd -c "commands"
-------------------------
So, try this:

{but first, with the process running, see who the owner is with the command:
ps -ef | grep screen
}

su - $M_USER -c "screen -d -m -S $NAME $DAEMON"

then do the command:
ps -ef | grep screen

and see who the owner is....


--------------------
Johnny Hughes
hughesjr@linuxhelp.net
Enterprise Alternatives: CentOS, WhiteBoxEL
Favorite Workstation Distros (in order): CentOS, Gentoo, Debian Sarge, Ubuntu, Mandrake, FedoraCore, Slackware, SUSE
Favorite Server Distros (in order): CentOS, WhiteBoxEL, Debian Sarge, Slackware, Mandrake, FedoraCore, Gentoo, SUSE
Go to the top of the page
 
+Quote Post
hughesjr
post Mar 4 2004, 08:45 AM
Post #3


Its GNU/Linuxhelp.net
*******

Group: Admin
Posts: 3,433
Joined: 25-July 03
From: Corpus Chrsiti, TX, USA
Member No.: 1,151



http://tille.soti.org/training/bash/index.html

http://ldp.linuxhelp.ca/HOWTO/Bash-Prog-In...ntro-HOWTO.html

http://gd.tuwien.ac.at/linuxcommand.org/wr...ell_scripts.php

http://ldp.linuxhelp.ca/LDP/abs/html/


--------------------
Johnny Hughes
hughesjr@linuxhelp.net
Enterprise Alternatives: CentOS, WhiteBoxEL
Favorite Workstation Distros (in order): CentOS, Gentoo, Debian Sarge, Ubuntu, Mandrake, FedoraCore, Slackware, SUSE
Favorite Server Distros (in order): CentOS, WhiteBoxEL, Debian Sarge, Slackware, Mandrake, FedoraCore, Gentoo, SUSE
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 17th October 2017 - 03:43 PM