Re: Running su scripts from bash scripts
| Newsgroups | gmane.org.user-groups.linux.morlug |
|---|---|
| Message-ID | <50034.141.153.121.71.1117942685.squirrel@webmail.unmatchedbracket.com> |
You might want to look into using "sudo". Sudo lets regular users run commands as another user (root unless otherwise specified). You could then edit /etc/sudoers to not request a password. That way, your script would look something like: cd Pictures/2005 mkisofs -r -o tmp/Pictures2005.iso . sudo cdrecord -v -data dev=0,0,0 tmp/Pictures2005.iso . > > I want to execute these commands in a single script: > > cd Pictures/2005 > mkisofs -r -o tmp/Pictures2005.iso . > su > cdrecord -v -data dev=0,0,0 tmp/Pictures2005.iso . > > The problem is that after it gets to su it never continues further with > the script. I know there is a way to do it in bash, but I forgot, and the > quick look at the reference material did not lead me to any example of > this kind. In short, I want to execute a set of super-user commands from > within a script. In the simples case, it's ok if the user executing the > script is asked to enter the root password. In the best case he'll not > have to. Any example of that would be appreciated. > > Andrei > > -- > --------------------------------------------- > Dr. Andrei Smirnov, West Virginia University > Dept. of Mechanical and Aerospace Engineering > Morgantown WV, 26506-6106 > Tel:+1(304)293 3111 x2345, fax:+1(304)2936689 > Email: [email protected] > http://smirnov.mae.wvu.edu 1024D/5CEDD3E2 > --------------------------------------------- > > _______________________________________________ > Morlug mailing list > [email protected] > http://mailman.morlug.org/mailman/listinfo/morlug >