You are not logged in.
Pages: 1
Hi all,
first time poster here. After making the switch from Ubuntu, I was faced with the uneasy task of configuring wireless networking for my stripped back Arch/ratpoison laptop via the command line (one of the prices to pay for a 30 MB of RAM build!), so I wrote this script to ease the pain of using wicd. I thought I'd share it here since this is my first bash script, I'm after ideas for expanding it's versatility in areas such as encrypted networks, more options etc etc (the sky/my stupidity is the limit). It's very primitive but it scans for wireless networks and then attempts to connect to one chosen by the user and then performs a ping to check it's connectivity.
All comments appreciated, thanks!
Best regards,
Chris
#! /bin/bash
#************************************************#
# wlan.sh #
# written by Chris Cummins #
# Oct 20, 2011 #
# #
# wicd-cli wizard. #
#************************************************#
ROOT_UID=0 #$UID for root privileges.
EXIT_NOTROOT=87 #Non-root exit error.
EXIT_USER=10 #User ended exit.
EXIT_PING=88 #Ping test faied exit error.
if [ "$UID" -ne "$ROOT_UID" ]
then
echo "Must be ran as root!"
exit $EXIT_NOTROOT
fi
echo "Scanning for wireless networks..."
echo
sudo wicd-cli -y -S #Scan for available networks.
sudo wicd-cli -y -l #Display available networks.
echo
#Prompt for network to connect to.
echo "Enter network # to connect to (left column):"
read network_id
if [ "$network_id" == "exit" ] #Exit command.
then
exit $EXIT_USER
fi
#Else...
echo "Attempting connection to network #$network_id..."
sudo wicd-cli -c -y --network $network_id #Connect to network.
echo
echo "Ping test:"
ping -c 3 -W 10 www.google.com #Test connection.
if [ $? == 0 ] #If passed test.
then
echo
echo "Connection successful."
else #If failed test.
echo
echo "Ping test failed!"
exit $EXIT_PING
fi
exit 0 #End script."Paradoxically, learning stuff is information-society enemy number one"
Offline
I've noticed that this site's 'code' feature has messed around with my tabbed comments a bit, how does it handle them? It's written with tab space set to 4.
"Paradoxically, learning stuff is information-society enemy number one"
Offline
Pages: 1