expect
#!/usr/bin/expect spawn ssh remotehost expect "*some key word*" send "kinit -f\r" expect "*assword*" send "password\r" send "cmd1\r" send "cmd2\r" send "df -h\r" send "hostname\r" send "date\r" interact
. /cfg
读取cfg文件中设置的环境变量,别名
从文件中读取
#!/usr/bin/expect set curPath "/path/config" set rpcData [exec cat "$curPath/rpc.txt"] set rec [exec cat "$curPath/ppw.txt"] set una [exec cat "$curPath/una.txt"] spawn ssh $una@$rpcData expect "*assw*" send "$rec\r" expect "*Micro*" send "pws\r" send "hostname\r" send "ipv4a\r" send "date\r" interact