分页: 1 / 2

expect问题?

发表于 : 2010-08-22 21:30
handyw
按照网上的ssh自动登录脚本写好,之前安装了expect但是运行脚本提示spawn not found ,expect not found ,怎么回事?

Re: expect问题?

发表于 : 2010-08-23 6:02
aerofox
expect 程序要用 expect 来解释
第一行加
#!/usr/bin/expect
或者
#!/usr/bin/env expect

Re: expect问题?

发表于 : 2010-08-23 9:28
handyw
已经加了还是不行,现在是spawn not found

Re: expect问题?

发表于 : 2010-08-23 9:43
xiooli
你确定安装了 expect 么?

运行 which expect 看看

Re: expect问题?

发表于 : 2010-08-23 9:48
handyw
which expect
/usr/bin/expect

Re: expect问题?

发表于 : 2010-08-23 10:35
eexpress
type expect 最容错了的。别which

Re: expect问题?

发表于 : 2010-08-23 18:19
aerofox
把完整的代码和出错信息贴出来。

Re: expect问题?

发表于 : 2010-08-23 21:29
tusooa
#!/usr/bin/env expect -f

6f:

代码: 全选

tlcr: 0 庚寅年七月十四日 21:20:18 ~
● which which
which: shell built-in command
tlcr: 0 庚寅年七月十四日 21:25:09 ~
● 

Re: expect问题?

发表于 : 2010-08-24 9:45
handyw
#!/usr/bin/expect
set timeout 60
spawn /usr/bin/ssh -D 7070 -g [email protected]
expect {
“password:” {
send “password\r”
#将第二个 password 改为你自己的密码
}
}
interact {
timeout 60 { send ” “}
}

按照这个来就是替换了自己的端口 username password 和ip地址,居然说spawn not found,expectnotfound

Re: expect问题?

发表于 : 2010-08-24 12:32
aerofox
执行时是输入文件名运行的吗?错误信息就这两条吗?

Re: expect问题?

发表于 : 2010-08-24 13:08
tusooa
ssh自动登录,用sssh。
那个daili.my貌似是fanqiang.org的。

Re: expect问题?

发表于 : 2010-08-24 13:14
handyw
还有什么password not found,什么语法错误

Re: expect问题?

发表于 : 2010-08-24 17:18
tusooa
跟你讲了,用sssh,会省不少麻烦。

Re: expect问题?

发表于 : 2010-08-30 14:05
handyw
我想知道出错的具体原因,不是要另外一种方法

Re: expect问题?

发表于 : 2010-08-30 14:12
tusooa
原因是#!你给输入成了`#!',结果让/bin/sh解释了。