From: anansi Date: 2007-06-13T21:10:09+09:00 Subject: Re: executing sudo from ruby thanks for your answers but that are no options here. I know hardcoded passes are in generally a bad idea but it's really needed here and safe. This is just a personal code on an offline pc with a highly encrypted partitions... Is there no way to give the pass as argument or pipe it or kind if that? But as said I need a technique working in both cases mentioned in the first post. Morten wrote: > anansi wrote: >> hi, >> I wanna execute in a script of mine commands like: "sudo apt-get >> clean" or "sudo nano /etc/X11/xorg.conf". The difference is: >> >> The first command needs to be executed without influence to the main >> process of the ruby scipt. It should simply be started as a second >> process totally independent from the ruby-script which invokes it. >> I think system("sudo apt-get clean") would be the right command. >> >> The second command should be this way that it is the only one after it >> has been executed. So the ruby-script should be stopped and therefor >> in the same console nano should be opened. >> I think exec("sudo nano /etc/X11/xorg.conf") would be the right command. >> >> But my problem is the password of sudo? How can I make my ruby-scipt >> give the password to sudo so I don't have to give it in every time? >> >> > > Set NOPASSWD in your sudoers file for the given commands, eg.: > > sudoeruser ALL=(ALL) NOPASSWD: /usr/bin/nano,/usr/bin/apt-get > > > Morten -- greets one must still have chaos in oneself to be able to give birth to a dancing star