expect interact后如何退出交互状态?

expect interact后如何退出交互状态?

expect interact后如何退出交互状态?      
exit
ctrl + d      
在 interact  里面调 return 就「回去」了       
复制内容到剪贴板
代码:
expect1.2> spanwn bash
invalid command name "spanwn"
    while executing
"spanwn bash"
expect1.3> spawn bash
spawn bash
6072
expect1.4> interact
apple@apple:~$ return
bash: return: can only `return' from a function or sourced script
apple@apple:~$
      
引用:
-(dearvoid@LinuxEden:Forum)-(~/void/expect)-
[$$=2393 $?=0] ; cat interact.exp
#!/bin/bash
# vi:set ts=8 sw=4 et sta ft=tcl:
#
# Author: <dearvoid at gmail.com>
#
# $Date: 2008-11-10 10:38:26 +0800 (Mon, 10 Nov 2008) $
# $HeadURL: https://dearvoid.googlecode.com/svn/trunk/expect/interact.exp $
# $Revision: 1495 $
#
#--------------------------------------------------------------------#
# \
exec expect "$0" "$@"
#
#--------------------------------------------------------------------#

proc expect_prompt {} \
{
    expect -re {#|$}
}

proc main {} \
{
    spawn bash --norc --noprofile
    expect_prompt

    send "echo Now interactive mode. Press CTRL-C to leave.\r"
    expect_prompt

    set bCtrlC false
    interact {
        \003 {
            set bCtrlC true
            return
        }
    }

    if { $bCtrlC } {
        send "\recho Now in non-interactive mode. Exiting ...\r"
        expect_prompt

        send "exit\r"
        expect eof
    }

    exit 0
}

main
-(dearvoid@LinuxEden:Forum)-(~/void/expect)-
[$$=2393 $?=0] ; ./interact.exp
spawn bash --norc --noprofile
bash-3.2# echo $'Now you\'re in interactive mode. To leave interactive mode, enter \033[1;31mCTRL-C\033[m.'
Now you're in interactive mode. To leave interactive mode, enter CTRL-C.
bash-3.2# echo 'blackspace 说俺骗人 '
blackspace 说俺骗人
--- 看到下面的提示符之后按 Ctrl-C ---
bash-3.2# echo Now you are back in non-interactive mode. Exiting ...
Now you are back in non-interactive mode. Exiting ...
bash-3.2# exit
exit
-(dearvoid@LinuxEden:Forum)-(~/void/expect)-
[$$=2393 $?=0] ; bye
      
复制内容到剪贴板
代码:
apple@apple:~$ expect
expect1.1> spawn bash
spawn bash
6353
expect1.2> interact +
apple@apple:~$ date
2008年 11月 10日 星期一 10:41:44 CST
apple@apple:~$
expect2.3> send "date\n"
expect2.4>
      
知道了,和interact后面的参数有关系      
不要随随便便给俺扔鸡蛋