You are not logged in.

#1 2012-07-11 13:43:08

mich04
Member
From: Illinois - United States
Registered: 2011-10-25
Posts: 390

using a script for wireless-tools [solved]

Can someone suggest a good way to start my wireless connection on boot using these three commands. I also have a user with limited access so I use the sudo command in front of all three.

iwconfig wlan0 essid dd-wrt
ip link set wlan0 up
dhcpcd wlan0

Last edited by mich04 (2012-07-11 19:41:56)


I love computers, networking and Arch Linux. Sometimes I might ask a stupid question, but please have grace with me like I would with you.

Offline

#2 2012-07-11 14:41:39

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,692

Re: using a script for wireless-tools [solved]


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#3 2012-07-11 14:47:44

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,499
Website

Re: using a script for wireless-tools [solved]

I was also thinking of suggesting netcfg or wicd, this is what they are for.  I no longer use either and just use a simple script - but it is not automated to run at boot.

I suspect the only practical way to have a script execute those commands with proper priveleges automatically on boot is to have an entry in your sudoers file for each one to not need a password, then put all three prepended by sudo in rc.local.

I suppose you could also make a script that runs all three, then have an entry for that script in sudoers and call the script with sudo from rc.local.

Of course there is the less practical way of writing a script/program to run like wicd or netcfg .... but if you're going to do that, why reinvent the wheel, just use one of those two.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#4 2012-07-11 15:00:12

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,692

Re: using a script for wireless-tools [solved]

BTW, I am with Trilby.  I personally use and recommend Wicd.  I want mine to run at boot so that when I reboot my machine remotely, I can talk to it when it comes back up.  Wicd did not quite answer the mail with regards to your specific question.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#5 2012-07-11 15:17:51

Gusar
Member
Registered: 2009-08-25
Posts: 3,607

Re: using a script for wireless-tools [solved]

rc.local runs as root so you don't need to mess with sudo if you put stuff in there.

Offline

#6 2012-07-11 16:21:00

vacant
Member
From: downstairs
Registered: 2004-11-05
Posts: 816

Re: using a script for wireless-tools [solved]

Have a look at systemd in the wiki.

I have

ExecStart=/sbin/ip link set dev ${interface} up
ExecStart=/usr/sbin/wpa_supplicant -B -i ${interface} -c /etc/wpa_supplicant/wpa_supplicant.conf
ExecStart=/sbin/ip addr add ${address}/${netmask} broadcast ${broadcast} dev ${interface}
ExecStart=/sbin/ip route add default via ${gateway}

included in /etc/systemd/system/network.service (I use a static IP address, and this connects to my WPA2 wireless network much quicker than wicd or netcfg).

Offline

#7 2012-07-11 17:05:36

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,499
Website

Re: using a script for wireless-tools [solved]

Gusar wrote:

rc.local runs as root so you don't need to mess with sudo if you put stuff in there.

I stand corrected.  This may then be the best bet if you don't want netfcg/wicd.  But be sure to background (and perhaps nohup) each command, or it will block the boot/login process until the network connection is complete.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#8 2012-07-11 18:21:12

mich04
Member
From: Illinois - United States
Registered: 2011-10-25
Posts: 390

Re: using a script for wireless-tools [solved]

Yea wicd, and the other programs always go so slow. So far I have been trying the rc.local route, it now goes straight to the desktop opens a terminal that has no borders asking me for a password than it continues the sequence and I have internet...a little more automated...it is too bad I can not incorporate it into slim. Although I do need furthur explaination on the code that would allow me to eliminate the password...here is what I have in rc.local

rxvt -e "sudo iwconfig wlan0 essid dd-wrt;ip link set wlan0 up;dhcpcd wlan0"

I love computers, networking and Arch Linux. Sometimes I might ask a stupid question, but please have grace with me like I would with you.

Offline

#9 2012-07-11 18:25:12

Gusar
Member
Registered: 2009-08-25
Posts: 3,607

Re: using a script for wireless-tools [solved]

Why rxvt? Put the commands directly rc.local, and like I said there's no need for sudo.

Offline

#10 2012-07-11 19:41:30

mich04
Member
From: Illinois - United States
Registered: 2011-10-25
Posts: 390

Re: using a script for wireless-tools [solved]

wow, thanks for the help using rc.local and putting the commands in their directly worked great for my situation, If I was going to have multiple accounts I would have just installed an actual program to handle this...but I feel as though with just one user who cares smile Thanks alot


I love computers, networking and Arch Linux. Sometimes I might ask a stupid question, but please have grace with me like I would with you.

Offline

#11 2012-07-11 19:43:27

mich04
Member
From: Illinois - United States
Registered: 2011-10-25
Posts: 390

Re: using a script for wireless-tools [solved]

now here is the question to ponder..is that an exploit of the system?...to easily plop commands into rc.local and have them run automagicly?


I love computers, networking and Arch Linux. Sometimes I might ask a stupid question, but please have grace with me like I would with you.

Offline

#12 2012-07-11 19:46:00

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,499
Website

Re: using a script for wireless-tools [solved]

It's no easier to "plop commands" into rc.local than it is into any other start up script.

If someone who should not have access to your system has root user priveleges, the yes that's a real problem - but rc.local is not unique in this.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#13 2012-07-11 19:50:07

mich04
Member
From: Illinois - United States
Registered: 2011-10-25
Posts: 390

Re: using a script for wireless-tools [solved]

true...ok well thanks guys and girls smile


I love computers, networking and Arch Linux. Sometimes I might ask a stupid question, but please have grace with me like I would with you.

Offline

Board footer

Powered by FluxBB