You are not logged in.

#1 2009-06-25 05:01:01

MattDark
Member
From: Chiapas, Mexico
Registered: 2009-06-25
Posts: 2

TinyWiFi: Network Manager From Terminal

What's up friends, my name is Mario Garcia, better known as Matt Dark, I'm from Mexico, I want to share a little application that I developed in order to get a network manager for my system, I installed Arch 3 months ago and I chose KDE as my graphical environment, but I didn't get a network manager during installation, I could compile it but I chose to program a little app, named TinyWiFi, that I want to share with you guys, I hope it will help you, every comment and suggestion is welcome. But for now it only runs in a terminal, I hope I will have time to designe a GUI for this tool. When all is said and done I give you the code.

tinywifi

#Mario A. Garcia (Matt Dark). Chiapas, Mexico
sudo ifconfig wlan0 up
sudo iwlist wlan0 scan > /usr/bin/red.txt
tinywifi.py
sudo rm /usr/bin/red.txt

This first code find wireless connections and shows a list with them. The application calls a python script that analize the result of scan and get connection to the chose network, and if it haves seccurity assigned, it asks for Wep Key.

tinywifi.py

#! /usr/bin/env python
#Mario A. Garcia (Matt Dark). Chiapas,Mexico
import os
#Open a text archive that contains the result of the scan
f = open("/usr/bin/red.txt", "r")
red={}
ch={}
ek={}
x=-1
c=-1
r=-1
while True:
      line = f.readline()          
      if not line: break
      #Save the name of ESSID
      if line.find("ESSID")>=0:
        x=x+1 
            word=line.split(":")
        red[x] = word[1]
        red[x] = red[x].replace('\n','')
      #Save the channel of connection
      if line.find("Channel:")>=0:
                c=c+1
                word=line.split(":")
                ch[c] = word[1]
        ch[c] = ch[c].replace('\n','')
      #Save the state of the encryption key (on/off)
      if line.find("Encryption key:")>=0:
                r=r+1
                word=line.split(":")
                ek[r] = word[1]
        ek[r] = ek[r].replace('\n','')
#List the name of connections available
for l in range (0,x+1):
    print str(l+1)+".-" + red[l]
n=int(raw_input('A que red desea conectarse: '))
n=n-1
#Analize the encryption key, in consecuence determine the need of a WEP Key
if ek[n] == "on":
    #Request encryption key
    k=raw_input('WEP Key: ')
    cm = "iwconfig wlan0 essid " + str(red[n]) +  " channel " + str(ch[n]) + " key " + str(k) + " & dhclient wlan0"
    os.system(cm)
else:
    cm = "iwconfig wlan0 essid " + str(red[n]) + " channel " + str(ch[n]) + " & dhclient wlan0"
    os.system(cm)

Copy both scripts to /usr/bin and give execution permissions (chmod +x). Don't forget to chance wlan0 for the name of your wireless interface. From terminal execute tinywifi to use this app. It is a simple application but it helped me, and i hope it will help you too. That's all for now. This is my first post but it won't be the last.

Last edited by MattDark (2009-06-25 05:37:51)


Love Is Like Linux, It's A Little Difficult To Explain

Offline

#2 2009-06-25 06:16:37

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: TinyWiFi: Network Manager From Terminal

Welcome to Arch, and thanks for your scripts. I think the first one is missing its shebang (#!/bin/sh).

I don't use KDE myself, but I expect there is netowrk manager support for it. Maybe someone else can answer that for you - although you seem to be happy with your own solution, so maybe it's not important to you anymore. smile

Offline

#3 2009-06-26 00:16:47

cdwillis
Member
From: /home/usa
Registered: 2008-11-20
Posts: 294

Re: TinyWiFi: Network Manager From Terminal

Thanks and welcome to the forum.

I'll have to try out your solution. I didn't see a network manager plugin when I installed KDE, but maybe I didn't look hard enough.

Offline

#4 2009-06-26 08:11:23

zenlord
Member
From: Belgium
Registered: 2006-05-24
Posts: 1,221
Website

Re: TinyWiFi: Network Manager From Terminal

Thank you for your script.

While it is set up differently, maybe you should have a look at netcfg, an Archlinux-specific app that is also CLI-based. netcfg works with profiles though and does not support connecting to a network that is not already a profile.

Offline

#5 2009-06-26 08:29:51

dying_sphynx
Member
From: Kiev, Ukraine
Registered: 2008-03-22
Posts: 44
Website

Re: TinyWiFi: Network Manager From Terminal

zenlord wrote:

While it is set up differently, maybe you should have a look at netcfg, an Archlinux-specific app that is also CLI-based. netcfg works with profiles though and does not support connecting to a network that is not already a profile.

Also you might find it intereresting wifi-select tool:

http://bbs.archlinux.org/viewtopic.php?id=63973

It's based on netcfg and supports connecting to a network that is not already a profile (by autogeneration profiles for netcfg).


With best regards,
Ivan N. Veselov.

Offline

Board footer

Powered by FluxBB