Skip to main content
added 30 characters in body
Source Link
glenn jackman
  • 88.6k
  • 16
  • 124
  • 179

First argument is hostname and second is password.

     #!/usr/bin/expect
     set pass [lindex $argv 1]
     set host [lindex $argv 0]
     spawn ssh -t root@$host echo Hello
     expect "*assword: "
     send "$pass\n";
     interact

Execution: ./script.expect

./script.expect hostname "my!password?"

First argument is hostname and second is password.

     #!/usr/bin/expect
     set pass [lindex $argv 1]
     set host [lindex $argv 0]
     spawn ssh -t root@$host echo Hello
     expect "*assword: "
     send "$pass\n";
     interact

Execution: ./script.expect

First argument is hostname and second is password.

     #!/usr/bin/expect
     set pass [lindex $argv 1]
     set host [lindex $argv 0]
     spawn ssh -t root@$host echo Hello
     expect "*assword: "
     send "$pass\n";
     interact

Execution:

./script.expect hostname "my!password?"
Source Link

First argument is hostname and second is password.

     #!/usr/bin/expect
     set pass [lindex $argv 1]
     set host [lindex $argv 0]
     spawn ssh -t root@$host echo Hello
     expect "*assword: "
     send "$pass\n";
     interact

Execution: ./script.expect