bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Help with script --


From: t0nedef
Subject: Help with script --
Date: Mon, 27 Aug 2007 16:55:15 -0700 (PDT)

Ok, i wrote this script to help with wpa wireless connections, but for some
reason, it errors out. It says that the ESSID is empty. I've double checked
my syntax, and it looks right to me. *yes, i did double check the syntax for
the read command*

well heres the code:

#!/bin/bash
#
# Script: wpa_helper
# Written by Mark A. LaDoux - t0nedef@haktstudios.com
# 
# copyright ©2007 Hakt Studios http://www.haktstudios.com
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

#Variables

ROOT_UID=0
WORK_PATH=/etc/wpa_helper # Storage directory DO NOT MODIFY
WORK_FILE=$WORKPATH/$ESSID.conf # Configuration file DO NOT MODIFY
DRIVER=wext # wpa driver to use, please modify it as necessary
IFACE=eth1 # network interface to use, please modify it as necessary



#Error Codes

E_NOTROOT=65   # user not root
E_NOESSID=66   # did not provide network name
E_USRDECL=67    # User Declined action

#Main Script

if [ $UID -ne $ROOT_UID ]
then
  echo "I am very sorry, but you do not currently have"
  echo "permissions to change network settings. Please"
  echo "contact your System Administrator."
  exit $E_NOTROOT
fi
## ok lets check for and set up some first time use stuff ##
if [ ! -e $WORKPATH ]
then
  echo "Thank you for choosing wpa_helper, I hope you enjoy"
  echo "this product. I will now create your initial"
  echo "configuration"
  mkdir $WORKPATH
fi
echo "Please enter a network name"
read ESSID
if [ -n $ESSID ]
then
  echo "unable to use a blank network name"
  exit $E_NOESSID
fi
if [ ! -e $WORKFILE ]
then
  echo "No current configuration for $ESSID currently"
  echo "Please enter the password for $ESSID"
  read PSK
  echo "network={" >> $WORKFILE
  echo "        ssid=\"$ESSID\"" >> $WORKFILE
  echo "        psk=\"$PSK\"" >> $WORKFILE
  echo "}" >> $WORKFILE
fi

wpa_assistant -D$DRIVER -i$IFACE -c$WORKFILE &
dhclient $IFACE
echo "Your wireless is now ready to use!"
exit 0

-- 
View this message in context: 
http://www.nabble.com/Help-with-script----tf4338503.html#a12358222
Sent from the Gnu - Bash mailing list archive at Nabble.com.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]