Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Author: Frash Pikass
- # Dependencies: expect
- if [ "$#" -eq "3" ]
- then
- (expect <<-finish
- #If it all goes pear shaped the script will timeout after 20 seconds.
- set timeout 20
- spawn telnet $1
- #The script expects login
- expect "login:"
- #The script sends the user variable
- send "$2\r"
- #The script expects Password
- expect "Password:"
- #The script sends the password variable
- send "$3\r"
- expect "#"
- send "ifconfig ppp0\r"
- expect "#"
- close
- finish
- ) | grep -o 'addr:[^ ]*' | sed s/addr://
- exit 0
- else
- echo "Usage: $0 gatewayRouterIP routerAdminUsername routerAdminPassword"
- exit 1
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement