├── CHANGELOG.md ├── LICENSE ├── README.md └── ptcli.sh /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | The changelog for PTCL CLI. 3 | 4 | ###1.1.0 (2017-01-31) 5 | - UPDATE: Auto reboot routine now works 6 | - UPDATE: Better documentation 7 | 8 | ###1.0.0 (2016-10-01) 9 | - First version 10 | - NEW: Reboot the router [ 1 | reboot ] 11 | - NEW: Router's system info [ 2 | sysinfo ] 12 | - NEW: Router's uptime [ 3 | uptime ] 13 | - NEW: ADSL info [ 4 | adsl_info ] 14 | - NEW: ADSL SNR check [ 5 | adsl_snr ] 15 | - NEW: Exit [ 6 | exit | q ] 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Ahmad Awais 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 13 | 18 | 19 |
5 | PTCL CLI
6 | An intuitive PTCL-CLI to control PTCL routers via command line. 7 |
11 | A FOSS (Free & Open Source Software) project. Maintained by @AhmadAwais. 12 | 14 | 15 | 16 | 17 |
20 | 21 | # PTCL-CLI (`ptcli`) 22 | `ptcli` is a bash CLI for PTCL routers. An intuitive PTCL-CLI to control PTCL routers via command line. 23 | 24 | ![PTCL-CLI](https://i.imgur.com/FHLLPAe.png) 25 | 26 | You can use `ptcli` to perform following actions via command line 27 | - Reboot the router 28 | - Check Router's system info 29 | - Check Router's uptime 30 | - Check ADSL info 31 | - Check & calculate ADSL SNR 32 | 33 | 34 | ## ⚡️ Installation 35 | 36 | Open command line terminal (I prefer iTerm2) and run the following command. 37 | 38 | ```bash 39 | sudo wget -qO ptcli https://git.io/vPmNx && sudo chmod +x ./ptcli && sudo install ./ptcli /usr/local/bin/ptcli 40 | ``` 41 | 42 | This command will perform the following actions: 43 | - Use sudo permissions 44 | - Use wget to download `PTCL-CLI` and rename it to `ptcli` 45 | - Make the `ptcli` executable 46 | - Install `ptcli` inside /usr/local/bin/ folder. 47 | 48 | ## 🙌 Usage 49 | ️ Usage: ptcli `[ -c |--config ]`, `[ -h | help ]` 50 | ️ - `[ -h | help ]` Use help 51 | - `[ -c | --config ]` Use config data, if so configure the three variables 'host_address', 'username', and 'password 52 | - `[ -r | --reboot ]` Quick reboot, dependant on '--config' param." 53 | 54 | Here's a complimentary GIF. 55 | 56 | ![PTCL-CLI GIF](https://i.imgur.com/TzeAw5B.gif) 57 | 58 | ## 🤔 Why was PTCL CLI Created? 59 | I am a command line junkie and it is too much work for me to go sign in and reboot the router or get the line parameters when I need to. So, I built this CLI and now with a bunch of aliases I am able to perform these actions within a single command. 60 | 61 | 62 | ## ⚡️ Environment 63 | I have built this CLI using Mac. It needs to be run on Bash or ZSH based shell. 64 | 65 | `Beta software! Use at your own risk.` 66 | 67 | ## ℹ️ Changelog 68 | 69 | ###1.1.0 (2017-01-31) 70 | - UPDATE: Auto reboot routine now works 71 | - UPDATE: Better documentation 72 | 73 | ###1.0.0 (2016-10-01) 74 | - First version 75 | - NEW: Reboot the router `[ 1 | reboot ]` 76 | - NEW: Router's system info `[ 2 | sysinfo ]` 77 | - NEW: Router's uptime `[ 3 | uptime ]` 78 | - NEW: ADSL info `[ 4 | adsl_info ]` 79 | - NEW: ADSL SNR check `[ 5 | adsl_snr ]` 80 | - NEW: Exit `[ 6 | exit | q ]` 81 | 82 | ## ℹ️ License 83 | MIT License. Copyrights . This script has no official affiliation with PTCL. 84 | 85 | --- 86 | 87 | ### 🙌 [THEDEVCOUPLE PARTNERS](https://TheDevCouple.com/partners) 88 | 89 | This open source project is maintained by the help of awesome businesses listed below. What? [Read more about it →](https://TheDevCouple.com/partners) 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 |
101 | 102 |
103 |
104 |

105 | For anything else, tweet at @MrAhmadAwais 106 |

107 | 108 |
109 |

I have released a video course to help you become a better developer — Become a VSCode Power User →

110 |
111 | 112 |
VSCode
113 | 114 | _VSCode Power User Course →_ 115 |
116 | -------------------------------------------------------------------------------- /ptcli.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | # Bash CLI for PTCL (`ptcli`). 3 | # 4 | # Version: 1.1.0 5 | # Author: Ahmad Awais 6 | # Author URL: http://AhmadAwais.com/ 7 | # 8 | #️ Usage: ptcli [ -c |--config ], [ -h | help ] 9 | #️ - [ -h | help ] Use help 10 | #️ - [ -c | --config ] Use config data, if so configure the three variables 'host_address', 'username', and 'password 11 | # - [ -r | --reboot ] Quick reboot, dependant on '--config' param." 12 | 13 | # if the config parameter is present then use the configuration. 14 | param=$1 15 | 16 | # Debugger. 17 | # echo "ℹ️ | DEBUG: Starting... | ℹ️ " 18 | 19 | # Check all params for config 20 | for i in "$@" ; do 21 | # Config. 22 | if [[ $i == "--config" || $i == "-c" ]] ; then 23 | is_config="yes" 24 | fi 25 | 26 | # Quick Reboot. 27 | if [[ $i == "-r" || $i == "--reboot" ]] ; then 28 | # Set the config. 29 | is_config="yes" 30 | is_reboot="yes" 31 | fi 32 | 33 | # Help. 34 | if [[ $i == "-h" || $i == "help" ]] ; then 35 | echo "——————————————————————————————————" 36 | echo "⚡️ Usage: ptcli [ -c |--config ], [ -h | help ]" 37 | echo "⚡️ - [ -h | help ] Use help." 38 | echo "⚡️ - [ -c | --config ] Use config data, if so configure the three variables 'host_address', 'username', and 'password'" 39 | echo "⚡️ - [ -r | --reboot ] Quick reboot, dependant on '--config' param." 40 | echo "——————————————————————————————————" 41 | fi 42 | done 43 | 44 | if [[ "$is_config" != "yes" ]]; then 45 | # $host_address host IP address to telnet. 46 | echo "——————————————————————————————————" 47 | echo "👉 IP address to telnet [E.g. 192.168.10.1 or 192.168.1.1]:" 48 | echo "——————————————————————————————————" 49 | read -r host_address 50 | 51 | # $username User to access. 52 | echo "——————————————————————————————————" 53 | echo "👉 ADMIN username [E.g. admin]:" 54 | echo "——————————————————————————————————" 55 | read -r username 56 | 57 | # $password User to access. 58 | echo "——————————————————————————————————" 59 | echo "👉 Password [E.g. Check the back of your router to find the password XXXXX]:" 60 | echo "——————————————————————————————————" 61 | read -r password 62 | else 63 | #.# Configure the variables if you don't like to enter them again and again. 64 | # Customize these variables as per your needs. 65 | 66 | # $host_address host IP address to telnet. 67 | host_address="192.168.10.1" 68 | 69 | # $username User to access. 70 | username="admin" 71 | 72 | # $password User to access. 73 | password="XXXXX" 74 | fi 75 | 76 | # If no auto reboot command, then ask for options. 77 | if [[ "$is_reboot" != "yes" ]]; then 78 | # $switch command switcher. 79 | echo "——————————————————————————————————" 80 | echo "👉 Enter what do you want to do? :" 81 | echo "␥ — Read the options below and chose an option by entering what's present in the square brackets E.g. [ command ]:" 82 | echo "␥ — 1. Reboot the router [ 1 | reboot ]:" 83 | echo "␥ — 2. Router's system info [ 2 | sysinfo ]:" 84 | echo "␥ — 3. Router's uptime [ 3 | uptime ]:" 85 | echo "␥ — 4. ADSL info [ 4 | adsl_info ]:" 86 | echo "␥ — 5. ADSL SNR check [ 5 | adsl_snr ]:" 87 | echo "␥ — 6. Exit [ 6 | exit | q ]:" 88 | echo "——————————————————————————————————" 89 | read -r switch 90 | else 91 | # If reboot -r triggered then just reboot it. 92 | switch="1" 93 | fi 94 | 95 | # echo "Wrong input, exitting!" 96 | while true 97 | do 98 | case $switch in 99 | 1|reboot ) echo "——————————————————————————————————"; echo "⏲ Rebooting..."; (sleep 1;echo "$username";sleep 1;echo "$password";sleep 1;echo "reboot"; sleep 1;) | telnet "$host_address"; echo "——————————————————————————————————"; break ;; 100 | 2|sysinfo ) echo "——————————————————————————————————"; echo "⏲ Printing Sysinfo..."; (sleep 1;echo "$username";sleep 1;echo "$password";sleep 1;echo "sysinfo"; sleep 1;) | telnet "$host_address"; echo "——————————————————————————————————"; break ;; 101 | 3|uptime ) echo "——————————————————————————————————"; echo "⏲ Printing uptime..."; (sleep 1;echo "$username";sleep 1;echo "$password";sleep 1;echo "uptime"; sleep 1;) | telnet "$host_address"; echo "——————————————————————————————————"; break ;; 102 | 4|adsl_info ) echo "——————————————————————————————————"; echo "⏲ Printing adsl_info..."; (sleep 1;echo "$username";sleep 1;echo "$password";sleep 1;echo "adsl info"; sleep 1;) | telnet "$host_address"; echo "——————————————————————————————————"; break ;; 103 | 5|adsl_snr ) echo "——————————————————————————————————"; echo "⏲ Printing adsl_snr..."; (sleep 1;echo "$username";sleep 1;echo "$password";sleep 1;echo "adsl info --SNR"; sleep 1;) | telnet "$host_address"; echo "——————————————————————————————————"; break ;; 104 | 6|exit|q ) echo "——————————————————————————————————"; echo "🙌 EXITING..."; echo "——————————————————————————————————"; exit;; 105 | * ) echo "——————————————————————————————————"; echo "❌ Wrong input! Try again!"; echo "——————————————————————————————————"; break ;; 106 | esac 107 | done 108 | --------------------------------------------------------------------------------