关于从定向
login.exp
#!/usr/bin/expect -f
set name [lindex $argv 0]
set server [lindex $argv 1]
spawn ssh $name@$server
expect "yes/no";
send "yes\r";
expect "password:";
send "oracle\r";
1.sh
#!/bin/sh
./login.exp owner 1.1.1.1>>1.txt
df -k
exit;
我现在需要把在1.1.1.1机器上此磁盘信息 保存到本地,我试了很多次未果,不是我想要的,该怎末做?
[解决办法]
其实也是很简单的,楼主的expect脚本不是很规范,很容易出问题的;
我写了一下: 你看看
#!/usr/bin/expect -f
set name [lindex $argv 0]
set server [lindex $argv 1]
spawn ssh $name@$server
expect "yes/no";
send "yes\r";
expect "*assword:";
expect "$";
send "df -k >>a.log";
expect {
"$"{
send"scp a.log 你的机器的目录\r"; #例子scp a.txt root@150.236.226.119:/home/
expect {
"$"{
send "exit\r";
expect eof
}
没有问题,楼主就给分吧,有问题发私信给我。
[解决办法]
scp/rsync/wget都可以。统称为下载。