Results 1 to 4 of 4

Thread: scripting help

  1. #1
    Join Date
    Dec 2007
    Location
    Science Station Hermes
    Beans
    611
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    scripting help

    Is there a way to store your user password in a script, such that any command in the script which requires sudo will run without prompting? Obviously security is not a concern here.
    Quote Originally Posted by Legendary_Bibo View Post
    I tried, and by tried I mean I did a half a**ed google search, and by half a**ed google search I mean I typed "eread pdg"

  2. #2
    Join Date
    Jan 2007
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: scripting help

    Here is one way to run a user script which requires a root password.

    Open the sudoers file vis visudo. Note - to edit the sudoers file the system uses vi. It can be confusing to new users. When it opens, select Edit. To insert a line, press I. Then type what you want. After you finish typing, hit the ESC key to get out of the editing mode. Then type :w to write/save your input. To exit, type :q

    Code:
    sudo visudo
    Enter the following text (example is for username dave and script /home/dave/Desktop/testscript.sh)

    Code:
    dave ALL= (root) NOPASSWD: /home/dave/Desktop/testscript.sh
    This script will now run without having to input the root password.

  3. #3
    Join Date
    Dec 2007
    Location
    Science Station Hermes
    Beans
    611
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: scripting help

    I tried that, but it is not actually the script that requires sudo, rather one of the lines in the script. The entire script is

    Code:
    #! /bin/sh
    sudo /usr/bin/vmware
    After editing sudoers for the script name, I tried it with and without sudo before the command. With sudo I get prompted for the p/w. Without I get the error I would expect to get if I ran it without sudo. I tried adding /usr/bin/vmware to the sudoers file instead, but I got the same error without sudo, and a different one with.

    Thanks though.

    BTW, when I ran the 'sudo visudo' command, it opened nano, not vi.
    Quote Originally Posted by Legendary_Bibo View Post
    I tried, and by tried I mean I did a half a**ed google search, and by half a**ed google search I mean I typed "eread pdg"

  4. #4
    Join Date
    Apr 2006
    Location
    Montana
    Beans
    Hidden!
    Distro
    Kubuntu Development Release

    Re: scripting help

    You can look at expect :

    Expect : Automate interactions (will pass passwords):

    http://www.linuxjournal.com/article/3065

    http://www.linux.com/articles/56066

    Or you can pipe the output of an echo command.
    There are two mistakes one can make along the road to truth...not going all the way, and not starting.
    --Prince Gautama Siddharta

    #ubuntuforums web interface

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
  •