免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1845 | 回复: 6
打印 上一主题 下一主题

shell 脚本 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-06-14 14:59 |只看该作者 |倒序浏览
我们学校用的是瑞捷,不想每次都手动联接,所以下载了expect-5.42 expect-devel-5.42 tcl-8.4安装后,编写了一个脚本,如下:
#! /usr/bin/expect
#supplicant
spawn xrgsu -a
expect "Please input your user name:"
send "120592004009\r"
expect "Please input your password:"
send "lijing\r"
expect "Use DHCP,1-Use,0-UnUse(Default: 0):"
send "\r"
expect "Use default auth parameter,0-Use 1-UnUse(Default: 0):"
send "\r"
expect "LogOff:"
sleep 1000
#end
在终端用sh auto-connect.sh运行出现错误如下:
auto-connect.sh: line 3: spawn: command not found
couldn't read file "Please input your user name:": no such file or directory
auto-connect.sh: line 5: send: command not found
couldn't read file "Please input your password:": no such file or directory
auto-connect.sh: line 7: send: command not found
couldn't read file "Use DHCP,1-Use,0-UnUse(Default: 0):": no such file or directory
auto-connect.sh: line 9: send: command not found
couldn't read file "Use default auth parameter,0-Use 1-UnUse(Default: 0):": no such file or directory
auto-connect.sh: line 11: send: command not found
couldn't read file "LogOff:": no such file or directory

我的内核是2.6.11,请高手们指教,万分感谢!

论坛徽章:
1
荣誉会员
日期:2011-11-23 16:44:17
2 [报告]
发表于 2007-06-14 15:12 |只看该作者
expect urscript

论坛徽章:
0
3 [报告]
发表于 2007-06-14 15:15 |只看该作者
原帖由 寂寞烈火 于 2007-6-14 15:12 发表于 2楼  
expect urscript


什么意思?不明白???

论坛徽章:
1
荣誉会员
日期:2011-11-23 16:44:17
4 [报告]
发表于 2007-06-14 15:22 |只看该作者
你这是一个expect脚本, 需要用expect去解释并执行,

论坛徽章:
0
5 [报告]
发表于 2007-06-14 17:14 |只看该作者
#! /usr/bin/expect
这句多了一个空格

论坛徽章:
0
6 [报告]
发表于 2007-06-14 23:12 |只看该作者
佩服楼上的,眼神真好

论坛徽章:
0
7 [报告]
发表于 2007-06-15 07:23 |只看该作者
多了空格不會有問題的, 某些老式的 Unix 更一定要有空格,不然會出錯
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP