ssh ist einfacher als telnet:
for host in host1 host2 host3; do ssh user@host remote_command with args done > result.file
Richten Sie für die Anmeldung ohne Kennwort die SSH-Schlüssel ein
Das wird Fehler haben, aber so etwas wie:
#!/usr/bin/env expect exp_internal 1 set out [open "results.txt" w] foreach ip $argv { spawn telnet $ip expect "password: " send "$password\r" expect "% " ;# this is the prompt, adjust to suit sent "the command\r" expect -re "([01,]+).*% " puts $out "$ip=$expect_out(1,string)" send exit expect eof exp_close wait } close $out