Learning scripting in Fedora
Hi,
I am learning scripting and Linux and I'm trying to create a very simple script that goes through a series of commands that set different aspects of the laptop I am using. It sets an static IP address, loads the wi-fi driver, and it goes to different folders to run certain commands needed to startup certain apps that I need running. My problem is that to run some of these applications I need to be as super user. How may I build the script so when a person starts it, he logs in as "su" and then the next commands are executed? I tried placing the "su" command inside the script, and when I test the script, it asks for the password, and after typing it, the script does not execute the next commands I put in the script... Thank you so much, RicG |
Hi,
I think you want to use "sude" rather than "su". This takes you into superuser mode. There is a discussion here: http://www.linuxquestions.org/questi...do-4175578489/ The only problem I see is that "sude" requires the user's password. I am not sure how to go about this. Cheers |
Learning scripting in Fedora
you can configure sudoers config file to allow a certain user passwordless access but preferably you should only allow your script itself to be run by that user.
|
You can just run the script with su
Code:
su -c "/path/to/script" |
Thank you all for your inputs.
I tried sude and it did not work. I'm still confused with the difference between "sudo" and "su". su -c "/path/to/script" worked. What do I need to use inside the script so when I run it, its output shows spaces in between the steps? Thanks again |
"sude" isn't a thing, he probably meant "sudo".
As for the difference between su and sudo: http://www.howtogeek.com/111479/htg-...tween-sudo-su/ They list some of the advantages of using sudo instead of su, but don't list any of the numerous disadvantages to disabling the root account and granting a regular user unlimited sudo power using their regular password, which irks me a bit. I don't believe Fedora enables sudo by default, which is why it didn't work. You would need to edit /etc/sudoers to grant sudo access to your user before you could use it. As for adding blank lines between output, you can use echo: Code:
$ cat script |
It all worked. Thank you very much.
The article was quite educational. RicG |
All times are GMT -5. The time now is 11:09 AM. |