expect问题?

sh/bash/dash/ksh/zsh等Shell脚本
handyw
帖子: 362
注册时间: 2007-06-11 13:06

expect问题?

#1

帖子 handyw » 2010-08-22 21:30

按照网上的ssh自动登录脚本写好,之前安装了expect但是运行脚本提示spawn not found ,expect not found ,怎么回事?
aerofox
帖子: 1453
注册时间: 2008-05-24 8:30

Re: expect问题?

#2

帖子 aerofox » 2010-08-23 6:02

expect 程序要用 expect 来解释
第一行加
#!/usr/bin/expect
或者
#!/usr/bin/env expect
handyw
帖子: 362
注册时间: 2007-06-11 13:06

Re: expect问题?

#3

帖子 handyw » 2010-08-23 9:28

已经加了还是不行,现在是spawn not found
头像
xiooli
帖子: 6956
注册时间: 2007-11-19 21:51
来自: 成都
联系:

Re: expect问题?

#4

帖子 xiooli » 2010-08-23 9:43

你确定安装了 expect 么?

运行 which expect 看看
handyw
帖子: 362
注册时间: 2007-06-11 13:06

Re: expect问题?

#5

帖子 handyw » 2010-08-23 9:48

which expect
/usr/bin/expect
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

Re: expect问题?

#6

帖子 eexpress » 2010-08-23 10:35

type expect 最容错了的。别which
● 鸣学
aerofox
帖子: 1453
注册时间: 2008-05-24 8:30

Re: expect问题?

#7

帖子 aerofox » 2010-08-23 18:19

把完整的代码和出错信息贴出来。
tusooa
帖子: 6548
注册时间: 2008-10-31 22:12
系统: 践兔
联系:

Re: expect问题?

#8

帖子 tusooa » 2010-08-23 21:29

#!/usr/bin/env expect -f

6f:

代码: 全选

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

代码: 全选

] ls -ld //
handyw
帖子: 362
注册时间: 2007-06-11 13:06

Re: expect问题?

#9

帖子 handyw » 2010-08-24 9:45

#!/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
aerofox
帖子: 1453
注册时间: 2008-05-24 8:30

Re: expect问题?

#10

帖子 aerofox » 2010-08-24 12:32

执行时是输入文件名运行的吗?错误信息就这两条吗?
tusooa
帖子: 6548
注册时间: 2008-10-31 22:12
系统: 践兔
联系:

Re: expect问题?

#11

帖子 tusooa » 2010-08-24 13:08

ssh自动登录,用sssh。
那个daili.my貌似是fanqiang.org的。

代码: 全选

] ls -ld //
handyw
帖子: 362
注册时间: 2007-06-11 13:06

Re: expect问题?

#12

帖子 handyw » 2010-08-24 13:14

还有什么password not found,什么语法错误
tusooa
帖子: 6548
注册时间: 2008-10-31 22:12
系统: 践兔
联系:

Re: expect问题?

#13

帖子 tusooa » 2010-08-24 17:18

跟你讲了,用sssh,会省不少麻烦。

代码: 全选

] ls -ld //
handyw
帖子: 362
注册时间: 2007-06-11 13:06

Re: expect问题?

#14

帖子 handyw » 2010-08-30 14:05

我想知道出错的具体原因,不是要另外一种方法
tusooa
帖子: 6548
注册时间: 2008-10-31 22:12
系统: 践兔
联系:

Re: expect问题?

#15

帖子 tusooa » 2010-08-30 14:12

原因是#!你给输入成了`#!',结果让/bin/sh解释了。

代码: 全选

] ls -ld //
回复