Permalink
Browse files

add remote ssh expect script

  • Loading branch information...
1 parent 65c58e6 commit 3067773944c4ec34ad55d70f544f240dcd1fa53b @poliva committed Sep 14, 2012
Showing with 37 additions and 0 deletions.
  1. +37 −0 expect/remote-ssh.expect
View
@@ -0,0 +1,37 @@
+#!/usr/bin/expect -f
+# (C) 2005 Pau Oliva - Licensed under GPLv2, for full terms see www.gnu.org
+set force_conservative 1 ;# set to 1 to force conservative mode even if
+ ;# script wasn't run conservatively originally
+if {$force_conservative} {
+ set send_slow {1 .001}
+ proc send {ignore arg} {
+ sleep .1
+ exp_send -s -- $arg
+ }
+}
+puts "\n"
+
+send_user "\n============================\n"
+send_user "$argv0 [lrange $argv 0 1]\n============================\n"
+spawn ssh -t -l root [lrange $argv 0 0]
+##expect {
+# "continue connecting (yes/no)*" {
+# send -- "yes\r"
+# }
+#}
+#expect "assword:*"
+#send -- "PASSWORD\r"
+#expect "#*"
+#send -- "\r"
+expect "#*"
+send -- "command\r"
+
+expect "#*"
+send -- "exit\r"
+
+expect {
+timeout {exit}
+-gl "\\\[*]\$*"
+}
+puts "\n"
+exit

0 comments on commit 3067773

Please sign in to comment.