Skip to Content
Linux Shell Scripting Cookbook - Third Edition
book

Linux Shell Scripting Cookbook - Third Edition

by Clif Flynt, Sarath Lakshman, Shantanu Tushar
May 2017
Beginner
552 pages
28h 47m
English
Packt Publishing
Content preview from Linux Shell Scripting Cookbook - Third Edition

How to do it...

This script will connect to a wireless LAN with WEP (Wired Equivalent Privacy):

#!/bin/bash 
#Filename: wlan_connect.sh 
#Description: Connect to Wireless LAN 

#Modify the parameters below according to your settings 
######### PARAMETERS ########### 
IFACE=wlan0 
IP_ADDR=192.168.1.5 
SUBNET_MASK=255.255.255.0 
GW=192.168.1.1 
HW_ADDR='00:1c:bf:87:25:d2'  
#Comment above line if you don't want to spoof mac address 

ESSID="homenet" 
WEP_KEY=8b140b20e7  
FREQ=2.462G 
################################# 

KEY_PART="" 

if [[ -n $WEP_KEY ]]; 
then 
  KEY_PART="key $WEP_KEY" 
fi 

if [ $UID -ne 0 ]; 
then 
  echo "Run as root" 
  exit 1; 
fi 

# Shut down the interface before setting new config 
/sbin/ifconfig $IFACE down 


if [[ -n $HW_ADDR ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Linux Shell Scripting - Second Edition

Mastering Linux Shell Scripting - Second Edition

Mokhtar Ebrahim, Andrew Mallett

Publisher Resources

ISBN: 9781785881985