Results 1 to 4 of 4
Ok this is really bugging me im trying to make a shell script that will let me do the ifconfig, iwconfig and dhcpcd in one easy step. I have tryed ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 10-18-2008 #1Just Joined!
- Join Date
- Oct 2008
- Location
- U.S.A
- Posts
- 23
Scripting help
Ok this is really bugging me im trying to make a shell script that will let me do the ifconfig, iwconfig and dhcpcd in one easy step. I have tryed makeing a executable shell script with the chmod +x filename.sh. hears what I have tryed to use and for some reason comeing to a metal block after hours of looking on the net.
if then script
#!/bin/bash
# the other stuff that gos hear
if /usr/Deamon
then
/bin/su
fi
if /sbin/iwconfig wlan0 essid
then
/sbin/iwconfig wlan0 essid any
fi
if /sbin/iwconfig wlan0 key off
then
/sbin/iwconfig wlan0 key ******** (I use my real key not *)
fi
if /sbin/iwconfig wlan0 ap
then
/sbin/iwconfig wlan0 ap auto
fi
if /sbin/dhcpcd
then
/sbin/dhcpcd wlan0
fi
Now I have also tryed
#!/bin/bash
#legal stuff
wlan0()
{
/sbin/iwconfig wlan0 essid any
/sbin/iwconfig wlan0 key ********
/sbin/iwconfig wlan0 ap auto
/sbin/dhcpcd wlan0
}
LST="iwconfig"
for wlan0 in $LST
do
wlan0
done
with the script above I get a error for each /sbin
Error for wireless request "Set ESSID" (8B1A) :
SET failed on device wlan0 ; Operation not permitted.
Error for wireless request "Set Encode" (8B2A) :
SET failed on device wlan0 ; Operation not permitted.
Error for wireless request "Set AP Address" (8B14) :
SET failed on device wlan0 ; Operation not permitted.
**** /sbin/dhcpcd: not a superuser
Now if I could figure out how to set up a superuser command line in that script I think it would work out just find but I just dont know
Sorry for all this I hate asking for help with stuff like this.
- 10-18-2008 #2
And if you run the script as root?
Can't tell an OS by it's GUI
- 10-18-2008 #3Just Joined!
- Join Date
- Oct 2008
- Location
- U.S.A
- Posts
- 23
they both work fine if im in root. Starts up my Wifi with no problem. I just need to figer out how to make my self a superuser then run the script then exit the shell. I can't use sudo just give me a error message after I type in the password. The reason I know I need to be a superuser/root is becase I have tyred to run the command one at a time in just normal user many times even after I changed the permisions on them for every on to use them. They are just su/root only commands.
- 10-19-2008 #4Just Joined!
- Join Date
- Oct 2008
- Location
- U.S.A
- Posts
- 23
Ok I think I found a way to add superuser to the if/then/else code just dont know how to echo it to see if its working or now any ways hears the code if some one can help me with any of this.
Code:#!/bin/bash #Copyright (C) 2008-10-17 Silverbain #email <silverbain@gmail.com> su() { if $passwd then passwd = <root password> fi }


Reply With Quote
