Connect to WiFi Access from command line in ubuntu / Linux without network manager using nmcli

 vim connect_to_wifi.sh 
#!/bin/sh
ACCESS_POINT_SSID=myaccesspoint_name
ACCESS_POINT_PASSWORD=myaccesspoint_password
echo "scanning..."
nmcli d wifi list

echo -n "connecting...."
#nmcli d wifi connect $ACCESS_POINT_SSID password $ACCESS_POINT_PASSWORD iface wlan0
nmcli d wifi connect $ACCESS_POINT_SSID password $ACCESS_POINT_PASSWORD
echo "done"

<<COMMENT
Usage: nmcli [OPTIONS] OBJECT { COMMAND | help }

OPTIONS
  -t[erse]                                   terse output
  -p[retty]                                  pretty output
  -m[ode] tabular|multiline                  output mode
  -c[olors] auto|yes|no                      whether to use colors in output
  -f[ields] <field1,field2,...>|all|common   specify fields to output
  -e[scape] yes|no                           escape columns separators in values
  -a[sk]                                     ask for missing parameters
  -s[how-secrets]                            allow displaying passwords
  -w[ait] <seconds>                          set timeout waiting for finishing operations
  -v[ersion]                                 show program version
  -h[elp]                                    print this help

OBJECT
  g[eneral]       NetworkManager's general status and operations
  n[etworking]    overall networking control
  r[adio]         NetworkManager radio switches
  c[onnection]    NetworkManager's connections
  d[evice]        devices managed by NetworkManager
  a[gent]         NetworkManager secret agent or polkit agent
  m[onitor]       monitor NetworkManager changes
COMMENT

$ bash connect_to_wifi.sh
scanning…
* SSID MODE CHAN RATE SIGNAL BARS SECURITY
myaccesspoint_name Infra 1 54 Mbit/s 62 ▂▄▆_ WPA1 WPA2
— Infra 8 54 Mbit/s 27 ▂___ WPA2
Device ‘wlan0’ successfully activated with ‘some-UUID’.
done

Android Android Commands Android Java Applications Application Libraries Bash / Shell Scripts Bluetooth driver Build Frameworks Commands and Packages Core Kernel C Programs Development Environment Setup Documents / Books Errors & Failures File Systems Framebuffer / Display Driver git Go Language Programs Hardware Platforms Home JAVA Programs Kernel & Device Drivers Kernel Booting and Porting Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL NDK / Middleware / HAL Network Driver OS Concepts PHP Procfs Filesystem Programming Languages RaspberryPi Scripting and Automation Search Engine Optimisation ( SEO ) Socurce Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Userspace Utilities Web design and development Wordpress Yocto / Bitbake / Openembedded
Tags:

Leave a Reply