Results 1 to 5 of 5

Thread: [SOLVED] sudo through bash script

  1. #1
    Join Date
    May 2008
    Location
    India
    Beans
    194
    Distro
    Ubuntu 11.04 Natty Narwhal

    [SOLVED] sudo through bash script

    Actually I was wondering, is there any kind of way to do "su" through bash "script".

  2. #2
    Join Date
    Aug 2006
    Location
    Yellowknife
    Beans
    878

    Re: sudo through bash script

    you mean so you aren't prompted to enter a password?

    echo yourpassword | sudo -S command

    VERY VERY VERY insecure! Probably better to create a password-less user that only has access to what your scripts needs (depending on what it needs)
    Last edited by decoherence; June 12th, 2008 at 03:23 PM. Reason: clarity

  3. #3
    Join Date
    May 2008
    Location
    India
    Beans
    194
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: sudo through bash script

    I know it's unsecure, but i just wanted it i don't know why. I also read man sudo after your post and found the flag -s. Thanx any ways.

  4. #4
    Join Date
    Feb 2006
    Location
    uk
    Beans
    Hidden!

    Re: sudo through bash script

    this is also useful if you're doing a string of commands and want the computer to shut down when they've finished.

    Code:
    wget http://this.com/thing.rar && rar -e thing.rar && rm thing.rar && echo yourpassword | sudo shutdown -h now && i can go to bed in peace

  5. #5
    Join Date
    Aug 2006
    Location
    Yellowknife
    Beans
    878

    Re: sudo through bash script

    heh i like that last command

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
  •