sudo/tests/use_pty-option/ssh-sudo.exp
Troy Dawson 864ea2c24c RHEL 9.0.0 Alpha bootstrap
The content of this branch was automatically imported from Fedora ELN
with the following as its source:
https://src.fedoraproject.org/rpms/sudo#68203ed1a2fac7aff1b57189e8c217db89e5fe4a
2020-10-15 10:06:29 -07:00

21 lines
421 B
Plaintext
Executable File

#!/usr/bin/expect -f
# usage:
# ./ssh-sudo.exp username password hostname command
set username [lrange $argv 0 0]
set password [lrange $argv 1 1]
set hostname [lrange $argv 2 2]
set command [lrange $argv 3 3]
set timeout 15
spawn ssh $username@$hostname sudo $command
expect "*yes/no*" {
send -- "yes\r"
}
expect "*assword*" {
send -- "$password\r"
}
expect "*assword*" {
send -- "$password\r"
}
expect eof