LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Mount / Script Question (https://www.linuxquestions.org/questions/linux-newbie-8/mount-script-question-340426/)

Centinul 07-05-2005 10:05 PM

Mount / Script Question
 
I would like to create a script that will mount my ipod and then run gtkpod all in one shot.

The problem is that the mount command requires root priveleges. Is there anyway I can make the script autologin as root? Thanks!

Dark_Helmet 07-05-2005 10:50 PM

Quote:

Is there anyway I can make the script autologin as root?
Bad, bad, bad idea :)

In short, no, there's no way for a script to run with root priviledges unless root executes it. The script can run "su" inside to gain root priviledge, but that will require user interaction to enter the root password. In my opinion, aside from the annoyance of entering the password everytime you run the script, having a script gain root privledges is a bad call. It would be better to use sudo for this.

Actually, you can eliminate all this root priviledge business by editing your /etc/fstab file. If you add "user" to the comma-separated list of options for your ipod entry, then a regular (i.e. non-root) user can mount and unmount the device at will. Here's an example using the entry I have for a USB pendrive:
Code:

/dev/pendrives/lexar      /media/pendrive  vfat    noauto,rw,user          0    0
Given that, your script becomes (with the mountpoint changed appropriately of course):
Code:

#!/bin/bash

mount /media/pendrive
gtkpod

And that's it.


All times are GMT -5. The time now is 06:01 AM.