Ubuntu under WiFi Connection No line by the script

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.