Skip to content

Instantly share code, notes, and snippets.

@strike
Last active April 10, 2017 14:02
Show Gist options
  • Save strike/98fc5cece1eb7a8d1570 to your computer and use it in GitHub Desktop.
Save strike/98fc5cece1eb7a8d1570 to your computer and use it in GitHub Desktop.
telnetpass - noninteractive ssh password provider (primitive sshpass for telnet)
#!/bin/bash
ip=`gethostip -d "$1"`
echo $ip
read -p "Which user-pass use? (G - GUU, M - marina or nothing) " prompt
case $prompt in
[Gg])
telnetpass "$ip" login pass en
;;
[Mm])
telnetpass "$ip" login pass
;;
*)
false
;;
esac
#!/usr/bin/expect -f
set host [lindex $argv 0]
set login [lindex $argv 1]
set pass [lindex $argv 2]
set command [lindex $argv 3]
spawn telnet $host
expect -re "User"
send "$login\n"
expect -re "Password"
send "$pass\n"
expect -re ">"
if { $command == "en" } {
send "$command\n"
expect -re "Password"
send "$pass\n"
} else {
send "$command\n"
}
interact
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment