Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: How to get wireless interface?

  1. #1
    hakermania's Avatar
    hakermania is offline Τώρα ξέρεις τι γράφω εδώ!
    Join Date
    Aug 2009
    Location
    Greece
    Beans
    1,704
    Distro
    Ubuntu Development Release

    Unhappy How to get wireless interface?

    ifconfig displays a lot of information, but im making a program and I was possible to take the current interface through the command
    Code:
    airmon-ng
    and some string editing.

    Unfortunately the above command is very slow, it does approximately 2 seconds to execute and my program hangs.

    Is there any secure way to take the current interface through ifconfig?
    Or is the interface written somewhere specifically like the hostname does? (/etc/hostname)

    Please mention that my program requires root permissions to run, so there is no problem with executing command requiring su permissions.

    Thanks in advance for any replies!
    Website

    Wallch (Wallpaper Changer): Sourceforge | Launchpad

  2. #2
    hakermania's Avatar
    hakermania is offline Τώρα ξέρεις τι γράφω εδώ!
    Join Date
    Aug 2009
    Location
    Greece
    Beans
    1,704
    Distro
    Ubuntu Development Release

    Re: How to get wireless interface?

    Well, I found my own way, but I cannot be sure that it will always work...
    Code:
    ifconfig > tmp;
    a=0; 
    while read line; do
    a=$(expr $a + 1);
    if [ $a -eq 18 ]; then
    b=${line%% *};
    fi;
    done < tmp
    rm tmp
    echo "'$b'"
    This will output 'wlan0' in my case but I cannot be sure that always and in every PC the interface is being outputed in the 18th line of $(ifconfig)!!!
    But if it does, then please post here that this works for you too...
    Website

    Wallch (Wallpaper Changer): Sourceforge | Launchpad

  3. #3
    Join Date
    Jun 2007
    Location
    Maryland, US
    Beans
    6,265
    Distro
    Kubuntu

    Re: How to get wireless interface?

    See if the contents of /proc/net/wireless can be used. On my two dissimilar Ubuntu systems, the third line contains the information you require.
    Code:
    Inter-| sta-|   Quality        |   Discarded packets               | Missed | WE
     face | tus | link level noise |  nwid  crypt   frag  retry   misc | beacon | 22
      eth1: 0000    5.  -54.  -57.       0    159      0   2309      0        0
    Check you system to see if in lieu of eth1, you have wlan0.

    P.S. I just checked an RHEL virtual machine that does not have a wireless interface. There was no third line in the output.
    Last edited by dwhitney67; May 21st, 2011 at 12:21 AM.

  4. #4
    hakermania's Avatar
    hakermania is offline Τώρα ξέρεις τι γράφω εδώ!
    Join Date
    Aug 2009
    Location
    Greece
    Beans
    1,704
    Distro
    Ubuntu Development Release

    Re: How to get wireless interface?

    the /proc/net/wireless file doesn't include the wlan0 string in my case :/
    I let the pc searching for files containing the word wlan0 and nothing interesting was found :/
    Website

    Wallch (Wallpaper Changer): Sourceforge | Launchpad

  5. #5
    hakermania's Avatar
    hakermania is offline Τώρα ξέρεις τι γράφω εδώ!
    Join Date
    Aug 2009
    Location
    Greece
    Beans
    1,704
    Distro
    Ubuntu Development Release

    Re: How to get wireless interface?

    What about the /proc/net/dev file? My interface appears on the 3rd line.....What about yours people out there?

    the /prov/net/arp says it clear, but i'm still not sure....
    Last edited by hakermania; May 22nd, 2011 at 05:56 PM.
    Website

    Wallch (Wallpaper Changer): Sourceforge | Launchpad

  6. #6
    Join Date
    Jan 2006
    Beans
    Hidden!
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: How to get wireless interface?

    Code:
    iwconfig 2>&1 | grep IEEE | awk '{print $1}'
    I am infallible, you should know that by now.
    "My favorite language is call STAR. It's extremely concise. It has exactly one verb '*', which does exactly what I want at the moment." --Larry Wall
    (02:15:31 PM) ***TimToady and snake oil go way back...
    42 lines of Perl - SHI - Home Site

  7. #7
    hakermania's Avatar
    hakermania is offline Τώρα ξέρεις τι γράφω εδώ!
    Join Date
    Aug 2009
    Location
    Greece
    Beans
    1,704
    Distro
    Ubuntu Development Release

    Question Re: How to get wireless interface?

    Quote Originally Posted by slavik View Post
    Code:
    iwconfig 2>&1 | grep IEEE | awk '{print $1}'
    I wasn't aware of the command 'iwconfig'.
    How do you guarantee that this is going to work at everybody running ubuntu-like OS and being in a laptop?
    Website

    Wallch (Wallpaper Changer): Sourceforge | Launchpad

  8. #8
    Join Date
    Jan 2006
    Beans
    Hidden!
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: How to get wireless interface?

    Code:
    slavik@home-main:~$ dpkg -S iwconfig
    wireless-tools: /usr/share/man/cs/man8/iwconfig.8.gz
    wireless-tools: /usr/share/man/fr.UTF-8/man8/iwconfig.8.gz
    wireless-tools: /usr/share/man/man8/iwconfig.8.gz
    wireless-tools: /usr/share/man/fr.ISO8859-1/man8/iwconfig.8.gz
    wireless-tools: /sbin/iwconfig
    slavik@home-main:~$ apt-cache showpkg wireless-tools 
    Package: wireless-tools
    Versions: 
    30~pre9-3ubuntu6 (/var/lib/apt/lists/us.archive.ubuntu.com_ubuntu_dists_natty_main_binary-amd64_Packages) (/var/lib/dpkg/status)
     Description Language: 
                     File: /var/lib/apt/lists/us.archive.ubuntu.com_ubuntu_dists_natty_main_binary-amd64_Packages
                      MD5: 34c7dc532552aa22b7a3e5860d0000e7
    
    
    Reverse Depends: 
      kubuntu-desktop,wireless-tools
      broadcom-sta-source,wireless-tools
      broadcom-sta-common,wireless-tools
      atmel-firmware,wireless-tools
      xubuntu-desktop,wireless-tools
      wifi-radar,wireless-tools
      wicd-daemon,wireless-tools
      whereami,wireless-tools
      ubuntustudio-desktop,wireless-tools
      ubuntu-sugar-remix,wireless-tools
      ubuntu-chinese-desktop,wireless-tools
      network-config,wireless-tools
      lubuntu-desktop,wireless-tools
      laptop-mode-tools,wireless-tools
      kismet,wireless-tools
      brdesktop-common,wireless-tools
      aircrack-ng,wireless-tools
      ubuntu-desktop,wireless-tools
      pm-utils,wireless-tools
      pcmciautils,wireless-tools
      linux-wlan-ng,wireless-tools
      kubuntu-desktop,wireless-tools
      acpi-support,wireless-tools
    Dependencies: 
    30~pre9-3ubuntu6 - libc6 (2 2.7) libiw30 (2 30~pre1) 
    Provides: 
    30~pre9-3ubuntu6 - 
    Reverse Provides: 
    slavik@home-main:~$
    Unless you remove (or modify) one of the -desktop packages (depends on the version of ubuntu you are using), dpkg is supposed to guarantee that it _WILL_ be there and available.
    I am infallible, you should know that by now.
    "My favorite language is call STAR. It's extremely concise. It has exactly one verb '*', which does exactly what I want at the moment." --Larry Wall
    (02:15:31 PM) ***TimToady and snake oil go way back...
    42 lines of Perl - SHI - Home Site

  9. #9
    hakermania's Avatar
    hakermania is offline Τώρα ξέρεις τι γράφω εδώ!
    Join Date
    Aug 2009
    Location
    Greece
    Beans
    1,704
    Distro
    Ubuntu Development Release

    Re: How to get wireless interface?

    I don't say that the iwconfig command won't be available but is can I take for granted that it will show the default interface on every pc?
    Website

    Wallch (Wallpaper Changer): Sourceforge | Launchpad

  10. #10
    Join Date
    Jan 2006
    Beans
    Hidden!
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: How to get wireless interface?

    there is no such thing as "the default interface"
    I am infallible, you should know that by now.
    "My favorite language is call STAR. It's extremely concise. It has exactly one verb '*', which does exactly what I want at the moment." --Larry Wall
    (02:15:31 PM) ***TimToady and snake oil go way back...
    42 lines of Perl - SHI - Home Site

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •