LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   initiate program as root (https://www.linuxquestions.org/questions/slackware-14/initiate-program-as-root-307055/)

Vindane 03-28-2005 12:40 PM

initiate program as root
 
I'm writing a script to connect to my wireless lan when I click on it. I've looked on google but can't seem to find what I'm looking for. I need to be root when these certain commands are given. My question is should I include the su command in my script? Or should I include the su command in my icon during the command call?

Code:

#! /bin/bash
# Script to connect to wireless lan.

modprobe ndiswrapper
iwconfig wlan0 mode Managed
iwconfig wlan0 key restricted 9999999999
iwconfig wlan0 essid ESSID
dhcpcd wlan0


XavierP 03-28-2005 01:57 PM

I'd set the permissions on that file to be only usable as root, it should then prompt you for a password.

gbonvehi 03-28-2005 02:23 PM

Make another script with these lines:
Code:

#! /bin/bash
su -c 'yourscripttogetwireless.sh'

or
Code:

#! /bin/bash
# Script to connect to wireless lan.

su -c 'modprobe ndiswrapper ; iwconfig wlan0 mode Managed ; iwconfig wlan0 key restricted 9999999999 ; iwconfig wlan0 essid ESSID ; dhcpcd wlan0'

:)

Oh, you could also take a look at sudo ('man sudo' and 'man sudoers') to see how to enable certain user to execute certain commands.


All times are GMT -5. The time now is 01:33 AM.