- 论坛徽章:
- 0
|
用EXPECT 做SCP的
如果第一次SCP 则应该匹配 YES/NO
如果不是第一次登录 则直接 匹配 PASSWORD 然后SEND 密码
帮我看下 这个脚本 老是不成功我
#!/usr/bin/expect
spawn scp -r ssh.sh haha@123.123.123.123:/home/zjh/
expect {
#"*yes/no*" { send "yes\r" }
"*password:" { send -- "123\r" }
}
老是 直接运行就结束了
我的EXPECT 版本是expect version 5.43.0
还有 能不能帮我在 判断YES/NO 那里 再进行深入判断 PASSWORD 我想如果第一次登录 则输入YES 然后直接输入密码 如果不是第一次则匹配密码 直接输入密码
求SHELL大拿出手相助啊
调试信息(IP和密码被我改了)
[oracle@host253 shell]$ ./scp.sh
expect version 5.43.0
argv[0] = /usr/bin/expect argv[1] = -d argv[2] = ./scp.sh
set argc 0
set argv0 "./scp.sh"
set argv ""
executing commands from command file ./scp.sh
spawn scp -r ssh.sh zjh@10.61.1.248:/home/zjh/
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {5524}
expect: does "" (spawn_id exp6) match glob pattern "*password*"? no
Address 10.61.1.248 maps to localhost, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT!
expect: does "Address 123.123.123.123maps to localhost, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT!\r\r\n" (spawn_id exp6) match glob pattern "*password*"? no
zjh@10.61.1.248's password:
expect: does "Address 123.123.123.123maps to localhost, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT!\r\r\nzjh@123.123.123.123·spassword: " (spawn_id exp6) match glob pattern "*password*"? yes
expect: set expect_out(0,string) "Address 123.123.123.123maps to localhost, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT!\r\r\nzjh@123.123.123.123password: "
expect: set expect_out(spawn_id) "exp6"
expect: set expect_out(buffer) "Address 123.123.123.123maps to localhost, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT!\r\r\nzjh@10.61.1.248's password: "
send: sending "123" to { exp6 }
是在看不出什么端倪
[ 本帖最后由 ztj2247 于 2009-6-29 20:29 编辑 ] |
|