Saturday, 15 March 2014

expect - Issuing commands on remote linux -



expect - Issuing commands on remote linux -

i'm looking way task expect:

mac-mini:~ root# scp file peter@mac-mini:file2 authenticity of host 'mac-mini (192.168.1.105)' can't established. rsa key fingerprint b6:12:3e:48:10:e6:d2:1f:8f:57:f4:01:2d:f3:23:89. sure want go on connecting (yes/no)? yes password: ********

and issue

crontab -l > crontab.src

#!/usr/bin/expect set machine0 "mac-minimini" set machine1 "mac-mini" set machine2 "mac-pro" ... set machine19 "mac-air" {set 1} {$i < 20} {incr 1} { eval spawn scp file peter@${machine${i}}:file2 expect "connecting (yes/no)?" send "yes\r" #use right prompt set prompt ":|#|\\\$" interact -o -nobuffer -re $prompt homecoming send "password\r" interact -o -nobuffer -re $prompt homecoming send "crontab -l > crontab.src\r" interact }

edit: can utilize loop , concatenate names each machine using variable of loop.(e.g. mac-mini0, mac-mini1, ... mac-mini19)

edit2: not sure if ${machine${i}} works worth try..

expect

No comments:

Post a Comment