Skip to content

Instantly share code, notes, and snippets.

@mohsinr
Forked from javikalsan/execute_on_router.sh
Created February 28, 2017 15:09
Show Gist options
  • Save mohsinr/2e76e2997aaeb15782dd0f43cebcc458 to your computer and use it in GitHub Desktop.
Save mohsinr/2e76e2997aaeb15782dd0f43cebcc458 to your computer and use it in GitHub Desktop.
Simple Bash Script to execute a command on the router through telnet command
#!/bin/sh
# replace cmd1 for the command to execute
host=192.168.1.1
port=23
user=admin
pass=02B08
cmd1='adsl info'
current_date_time="`date +%Y-%m-%d\ %H:%M:%S`";
( echo open ${host}
sleep 1
echo ${user}
sleep 1
echo ${pass}
sleep 1
echo ${cmd1}
sleep 2
) | telnet | tee -a txt.txt
echo $current_date_time | tee -a txt.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment