Results 1 to 6 of 6

Thread: Run script without sudo passwd

  1. #1
    Join Date
    May 2007
    Beans
    41

    Question Run script without sudo passwd

    I am trying to run a script at startup that requires sudo priviledges. What is does is run the smbmount command to mount a network drive. How can I run this without sudo passwd? I edited sudoers and tried both these lines:

    jmasgalas ALL=NOPASSWD: /usr/bin/smbmount
    jmasgalas ALL=NOPASSWD: /home/jmasgalas/mountscript


    It still does not work. Here is the exact command in the script:

    sudo smbmount //server/share /mnt/H -o username=xxxx,password=xxxx,file_mode=0777,dir_mod e=0777

    What am I doing wrong?

  2. #2
    Join Date
    Jun 2007
    Location
    Leeds, UK
    Beans
    159
    Distro
    Kubuntu 10.10 Maverick Meerkat

    Re: Run script without sudo passwd

    Why do you want to run without sudo? If the script needs to access root files then it'll need sudo privileges.

  3. #3
    Join Date
    May 2007
    Beans
    41

    Re: Run script without sudo passwd

    I want it to run on startup. Right now it does not work because it needs sudo priviledges.

  4. #4
    Join Date
    Mar 2008
    Location
    California, USA
    Beans
    8,111

    Re: Run script without sudo passwd

    Quote Originally Posted by jmasgalas View Post
    I am trying to run a script at startup that requires sudo priviledges. What is does is run the smbmount command to mount a network drive. How can I run this without sudo passwd? I edited sudoers and tried both these lines:

    jmasgalas ALL=NOPASSWD: /usr/bin/smbmount
    jmasgalas ALL=NOPASSWD: /home/jmasgalas/mountscript


    It still does not work. Here is the exact command in the script:

    sudo smbmount //server/share /mnt/H -o username=xxxx,password=xxxx,file_mode=0777,dir_mod e=0777

    What am I doing wrong?
    You actually don't need to mess with modifying your sudoers file in this case; if you want to run any commands/scripts on startup as root, just stick them in your /etc/rc.local file. All commands/scripts in rc.local get executed as root, so no need to put sudo in front of them in that file.

    Also, if you haven't done it all ready, I would first try that smbmount command out on the command line to make sure you have it exactly right.

  5. #5
    Join Date
    Mar 2008
    Location
    City of Pines
    Beans
    3,585

    Re: Run script without sudo passwd

    Try to make your script executable

    Code:
    sudo chmod +x <script_name>
    Copy the script to /etc/init.d directory.

    Code:
    sudo cp <script_name> /etc/init.d
    Execute the update-rc.d <script_name> defaults command as root

    Code:
    update-rc.d <script_name> defaults
    Steady movement is more important than speed, much of the time. So long as there is a regular progression of Stimuli to get your mental hooks into, there is room for lateral movement. Once this begins, its rate is a matter of discretion.

  6. #6
    Join Date
    May 2008
    Location
    The Pitts Burgh
    Beans
    169
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Run script without sudo passwd

    I have a script to connect to my bluetooth mouse. Ordinarily, the command is sudo hidd -s, after which I have to input my password. The script I wrote, however, does it for me, so this might work for you:

    Code:
    sudo hidd -s &&
    mypassword
    This doesn't work in an application launcher, but running the file path to the script in the launcher does connect my mouse (I just have to type /home/beth/etc. to run it, or actually double-click on it, instead of typing sudo hidd -s $$ mypassword as the command to run with the launcher.)

    Give that a try. I hope it works.
    Veni, vidi, dormivi.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •