Re: Running su scripts from bash scripts
Michael Bond <[email protected]>
| Newsgroups | gmane.org.user-groups.linux.morlug |
|---|---|
| Message-ID | <[email protected]> |
Method 5: Use an expects script to handle it asking for a password. Though, i highly recommend you don't use this option, it is still another option. I would probably choose the "sudo" access option that Dave Riggs mentioned above. Mike. [email protected] On Jun 4, 2005, at 6:18 PM, David A. Riggs wrote: > On Sat, 2005-06-04 at 10:15 -0400, Andrei Smirnov wrote: > >> 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. >> >> > > > Method 1: Make cdrecord SUID Root > > This lets normal users execute cdrecord with root privileges, which > is a > possible security risk. You should likely restrict this to being group > executable if you care. Your script stays the same, but you remove the > 'su' line. > > shell> chown root:root `which cdrecord` > shell> chmod 4111 `which cdrecord` > > > Method 2: 'sudo' Access > > Read the documentation on 'sudo' and set up your user or group to have > passwordless sudo access to cdrecord. Ditto on security concerns. Your > script removes the 'su' line and prepends cdrecord with 'sudo > cdrecord...'. You don't even have to make it passwordless if you're > worried about security. > > > Method 3: Use gnome/kde > > Install the nautilus-cd-burner extension or whatever konq's equivalent > is. Right click the folder Pictures/2005 and choose "burn to CD". > Recent > gnome makes you choose "Go -> CD/DVD Creator" and drag files or > folders > into it. Why deal with the details of creating an iso9660 > filesystem and > figuring out which virtual SCSI device to use when the GUI already > knows? > > Method 4: gksu > > Replace the last two lines with 'gksu cdrecord...' and a pretty GTK > box > will ask you for the root password and execute your command. > > > - David A. Riggs <riggs at csee dot wvu dot edu> > > _______________________________________________ > Morlug mailing list > [email protected] > http://mailman.morlug.org/mailman/listinfo/morlug >