当前位置: 技术问答>linux和unix
ubuntu 下请教一个关于 expect 的脚本
来源: 互联网 发布时间:2016-09-29
本文导语: 我改了 /etc/asterisk/sip.conf 的内容 ,现在想使它生效 ,可以输入命令 sudo asterisk -r 进入 heizi-desktop*CLI> 输入 sip reload 然后 heizi-desktop*CLI> 输入exit OK , 现在我写了个脚本,希望可以 执行交互的功能,...
我改了 /etc/asterisk/sip.conf 的内容 ,现在想使它生效 ,可以输入命令 sudo asterisk -r 进入
heizi-desktop*CLI> 输入 sip reload 然后 heizi-desktop*CLI> 输入exit OK ,
现在我写了个脚本,希望可以 执行交互的功能,脚本如下:
#! /usr/bin/expect -f
spawn sudo asterisk -r
expect "heizi-desktop*CLI> "
send "sip reloadr"
expect "heizi-desktop*CLI> "
send "exitr"
expect eof
打印信息如下 : heizi@heizi-desktop:~/zhouzeming$ ./asterisk
spawn sudo asterisk -r
Asterisk 1.6.2.5-0ubuntu1, Copyright (C) 1999 - 2009 Digium, Inc. and others.
Created by Mark Spencer
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Connected to Asterisk 1.6.2.5-0ubuntu1 currently running on heizi-desktop (pid = 1405)
heizi-desktop*CLI> sip reload
heizi-desktop*CLI> exit
heizi@heizi-desktop:~/zhouzeming$
但是sip reload 没有实现啊? 这是为什么呢?
heizi-desktop*CLI> 输入 sip reload 然后 heizi-desktop*CLI> 输入exit OK ,
现在我写了个脚本,希望可以 执行交互的功能,脚本如下:
#! /usr/bin/expect -f
spawn sudo asterisk -r
expect "heizi-desktop*CLI> "
send "sip reloadr"
expect "heizi-desktop*CLI> "
send "exitr"
expect eof
打印信息如下 : heizi@heizi-desktop:~/zhouzeming$ ./asterisk
spawn sudo asterisk -r
Asterisk 1.6.2.5-0ubuntu1, Copyright (C) 1999 - 2009 Digium, Inc. and others.
Created by Mark Spencer
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Connected to Asterisk 1.6.2.5-0ubuntu1 currently running on heizi-desktop (pid = 1405)
heizi-desktop*CLI> sip reload
heizi-desktop*CLI> exit
heizi@heizi-desktop:~/zhouzeming$
但是sip reload 没有实现啊? 这是为什么呢?
|
上次你那个贴 大家都已经讨论了 还没解决 不知道咋回事了
|
上次你那个贴 大家都已经讨论了 还没解决 不知道咋回事了