Active Topics

 


Reply
Thread Tools
Posts: 12 | Thanked: 5 times | Joined on Jul 2008
#1
Apologies if this isn't the place to put it, but I know I'd looked for this elsewhere, and hadn't found a command to do this. It'll allow you to manage connections from scripts. Only three parameters; -c iapname to connect and -d to disconnect, whereas -i iapname simply returns the id. Any network names containing spaces should be enclosed by quotes. Also, if the tablet is already connected, you need to disconnect first. On my my tablet, I've placed it at /usr/bin/wifitool.

Code:
#!/bin/sh

# shell script to connect/disconnect from APs by name

iapidbyname() {
   gconftool-2 --all-dirs /system/osso/connectivity/IAP | while read LINE
   do
      if [ $1 == "`gconftool-2 -g $LINE/name 2>/dev/null`" ]; then
         echo $LINE | sed 's|/system/osso/connectivity/IAP/\([0-9abcdef-]*\)|\1|'
         break
      fi
   done
}

# connect by name
if [ "$1" == "-c" ] || [ "$1" == "--connect" ]; then
   IAP=`iapidbyname $2`
   if [ $IAP ]; then
      dbus-send --type=method_call --system --dest=com.nokia.icd /com/nokia/icd com.nokia.icd.connect string:${IAP} uint32:0
      exit 0
   else
      echo "Network name not found"
      exit 1
   fi
fi

# disconnect
if [ "$1" == "-d" ] || [ "$1" == "--disconnect"  ]; then
   dbus-send --system --dest=com.nokia.icd /com/nokia/icd_ui com.nokia.icd_ui.disconnect boolean:true
   exit 0
fi

# return id for name
if [ "$1" == "-i" ] || [ "$1" == "--id" ]; then
   IAP=`iapidbyname $2`
   if [ $IAP ]; then
      echo $IAP
      exit 0
   else
      echo "Network name not found"
      exit 1
   fi
fi

# Output Help
echo "Usage: $0 option [IAP]"
echo "Option    GNU long option  Meaning"
echo " -h, -?   --help           Show this message"
echo " -c <IAP> --connect <IAP>  Connect to Internet Access Point"
echo " -d       --disconnect     Disconnect current connection"
echo " -i <IAP> --id <IAP>       Show osso id for named IAP"

exit 1
Updated in response to comments. Thanks!
Attached Files
File Type: gz wifitool.gz (616 Bytes, 165 views)

Last edited by ichneumon; 2009-01-11 at 18:09. Reason: Script update
 

The Following 3 Users Say Thank You to ichneumon For This Useful Post:
allnameswereout's Avatar
Posts: 3,397 | Thanked: 1,212 times | Joined on Jul 2008 @ Netherlands
#2
Hmm, some AP names contain spaces. Then you need quotes; e.g. wifitool -c "Home Sweet Home"

This should be pretty useful for those who decide to use a newer kernel, not being able to use the connection panel.
__________________
Goosfraba! All text written by allnameswereout is public domain unless stated otherwise. Thank you for sharing your output!
 

The Following User Says Thank You to allnameswereout For This Useful Post:
Posts: 755 | Thanked: 406 times | Joined on Feb 2008 @ UK
#3
Code:
#!/bin/sh
May also be slightly more appropriate for those who don't have bash installed (provided there isn't anything in there that's bash specific)
 

The Following User Says Thank You to codeMonkey For This Useful Post:
Posts: 191 | Thanked: 29 times | Joined on Sep 2007 @ Ottawa
#4
Look interesting. My only comment, would be to add help, with something like this:

#!/bin/sh

if [ -z $1 ]; then
# needs help
echo "Help is available"
exit
fi

echo "No Help"
__________________
N800, Think Outside Kbd, 8GB SDHC Card (OCZ, ext2), and 8GB SD Card (Patriot formatted as VFAT)
Zaurus SL-6000, IR Keyboard, 1GB SD Card
 

The Following User Says Thank You to cvmiller For This Useful Post:
Banned | Posts: 34 | Thanked: 3 times | Joined on Jul 2011
#5
-it connect to only saved ap,,,i want an scripts for connect to no-saved ap
tanks
 
Reply


 
Forum Jump


All times are GMT. The time now is 11:52.