ubuntu under WiFi Connection No line by the script
Mainly use command line, control WiFi interface to connect wireless router, write a simple script, for reference only!
[email protected]:~$ cat wifi-link.sh#!/bin/sh## author leekwen#read-p "Enter wifi SSID Name:" Ssidecho "\ n \033[32 M the WIFI SSID is $ssid. \033[0m \ read-p "Enter The password of SSID:" Passwordecho "\ n \033[32m the password is $password \033[0m\n" wpa_passphr ASE $ssid $password >/etc/wpa_supplicant.confwpa= ' ps-ef |grep wpa_supplicant|grep-v "grep" |wc-l ' dhc= ' Ps-ef |grep "Dhclient wlan0" |grep-v "grep" |wc-l ' #echo "Dhclient is $dhc" pid= ' pgrep wpa_supplicant ' cid= ' ps-ef |grep ' dhclient wla N0 "|grep-v" grep "|awk ' {print $} ' #echo $cidif [$wpa-eq 0]; Then echo ' process is None ' Wpa_supplicant-b-dwext-iwlan0-c/etc/wpa_supplicant.conf & If [ $cid-eq 0]; Then Dhclient Wlan0 & Else kill $cid sleep 1; Dhclient Wlan0 & fielse echo "\ n \033[31m the process is exists ... \033[0m \ n" #echo $pid Kill $pid & Sleep 1 ECho "\ \033[31m the interface would restart ... \033[0m \ n" wpa_supplicant-b-dwext-iwlan0-c/etc/wpa_supplic Ant.conf & If [$cid-eq 0]; Then Dhclient Wlan0 & Else Kill $cid Sleep 1; Dhclient Wlan0 & Fifi
When prompted to enter the SSID name and password for WiFi, the WiFi interface automatically restarts and dynamically obtains the IP address from the route.
If the interface name of the WiFi is non-wlan0, modify the script yourself to make it easier for you to use.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Ubuntu under WiFi Connection No line by the script