liu1014020126 2015-05-21 01:28 采纳率: 0%
浏览 23587

expetc脚本报错问题spawn id exp6 not open

先贴代码 主要我用一个shell脚本实现增加linux用户的功能

1 #!/usr/bin/expect -f
2 #!/bin/sh
3 set password 1
4 set name yiyi
5 set num ""
6 spawn adduser $name
7 set timeout 30;
8 expect {
9 password: {send $password\n;exp_continue};
10 password: {send $password\n;exp_continue};
11 *[]: {send $num\n;exp_continue};
12 *[]: {send $num\n;exp_continue};
13 Phone: {send $num\n;exp_continue};
14 Phone: {send $num\n;exp_continue};
15 Other: {send $num\n;exp_continue};
16 }
17 set timeout 30
18 expect "Is the information correct?"
19 send "Y\r"
20 set timeout 30;
21 send exit\n;
22 expect eof

执行完就以报如下错误求大神解决啊:
expect: spawn id exp6 not open
while executing
"expect "Is the information correct?""
(file "./adduser.sh" line 18)

  • 写回答

4条回答 默认 最新

  • nswcfd 2015-05-28 01:28
    关注

    因为第8行开始的expect里面包含exp_continue,所以这个expct {}(8-16行)的行为是个loop,会一直run 到 eof ,
    再继续执行18行的expect的时候,已经没有input了,就打印id exp6 not open的错误。
    所以需要把后面的expect合并到这个block里面。

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器