亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫(kù)
最近訪(fǎng)問(wèn)板塊 發(fā)新帖
查看: 6274 | 回復(fù): 2
打印 上一主題 下一主題

請(qǐng)問(wèn)關(guān)于expect參數(shù)傳遞的問(wèn)題。 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2008-07-31 15:13 |只看該作者 |倒序?yàn)g覽
說(shuō)不明白。直接貼代碼吧。

spawn ssh -p22 root@****
expect "password:"
send "******\r"
expect " ~]#"
send "/root/config1.sh $argv 1 $argv 2 $argv 3\r"
expect " ~]#"
send "/root/config2.sh\r"
close
exit 0
~

#expect test.sh 1 2 3
spawn ssh -p22 root@****
root@10.10.234.80's password:
Last login: Mon Jul 28 13:02:15 2008 from *****
[root@localhost ~]# /root/config1.sh 1 2 3 1 1 2 3 2 1 2 3 3


在向config1.sh傳遞參數(shù)的時(shí)候?偸悄涿畹亩鄮讉(gè)參數(shù)。。

還有。。它總是少執(zhí)行一條send語(yǔ)句(config2.sh沒(méi)有被執(zhí)行)。。

如果send只有語(yǔ)句只有一條,根本不執(zhí)行,

下邊是expect -d的調(diào)試信息
linux-qzyh:~ # expect -d test.sh 1 2 3
expect version 5.44.1.5
argv[0] = expect  argv[1] = -d  argv[2] = test.sh  argv[3] = 1  argv[4] = 2  argv[5] = 3
set argc 3
set argv0 "test.sh"
set argv "1 2 3"
executing commands from command file test.sh
spawn ssh -p22 root@*******
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {4141}

expect: does "" (spawn_id exp6) match glob pattern "password:"? no
root@*********'s password:
expect: does "root@10.10.234.80's password: " (spawn_id exp6) match glob pattern "password:"? yes
expect: set expect_out(0,string) "password:"
expect: set expect_out(spawn_id) "exp6"
expect: set expect_out(buffer) "root@10.10.234.80's password:"
send: sending "*******\r" to { exp6 }

expect: does " " (spawn_id exp6) match glob pattern " ~]#"? no


expect: does " \r\n" (spawn_id exp6) match glob pattern " ~]#"? no
Last login: Mon Jul 28 13:04:28 2008 from *******

expect: does " \r\nLast login: Mon Jul 28 13:04:28 2008 from *******\r\r\n" (spawn_id exp6) match glob pattern " ~]#"? no

expect: does " \r\nLast login: Mon Jul 28 13:04:28 2008 from *******\r\r\n\u001b]0;root@localhost:~\u0007" (spawn_id exp6) match glob pattern " ~]#"? no
[root@localhost ~]#
expect: does " \r\nLast login: Mon Jul 28 13:04:28 2008 from *******\r\r\n\u001b]0;root@localhost:~\u0007[root@localhost ~]# " (spawn_id exp6) match glob pattern " ~]#"? yes
expect: set expect_out(0,string) " ~]#"
expect: set expect_out(spawn_id) "exp6"
expect: set expect_out(buffer) " \r\nLast login: Mon Jul 28 13:04:28 2008 from *******\r\r\n\u001b]0;root@localhost:~\u0007[root@localhost ~]#"
send: sending "/root/config1.sh 1 2 3 1 1 2 3 2 1 2 3 3\r" to { exp6 }

expect: does " " (spawn_id exp6) match glob pattern " ~]#"? no
/r
expect: does " /r" (spawn_id exp6) match glob pattern " ~]#"? no
oot/
expect: does " /root/" (spawn_id exp6) match glob pattern " ~]#"? no
con
expect: does " /root/con" (spawn_id exp6) match glob pattern " ~]#"? no
f
expect: does " /root/conf" (spawn_id exp6) match glob pattern " ~]#"? no
ig
expect: does " /root/config" (spawn_id exp6) match glob pattern " ~]#"? no
1
expect: does " /root/config1" (spawn_id exp6) match glob pattern " ~]#"? no
.s
expect: does " /root/config1.s" (spawn_id exp6) match glob pattern " ~]#"? no
h 1 2
expect: does " /root/config1.sh 1 2 " (spawn_id exp6) match glob pattern " ~]#"? no
3 1 1 2 3 2 1 2 3 3

expect: does " /root/config1.sh 1 2 3 1 1 2 3 2 1 2 3 3\r\n" (spawn_id exp6) match glob pattern " ~]#"? no

expect: does " /root/config1.sh 1 2 3 1 1 2 3 2 1 2 3 3\r\n\u001b]0;root@localhost:~\u0007" (spawn_id exp6) match glob pattern " ~]#"? no
[root@localhost ~]#
expect: does " /root/config1.sh 1 2 3 1 1 2 3 2 1 2 3 3\r\n\u001b]0;root@localhost:~\u0007[root@localhost ~]# " (spawn_id exp6) match glob pattern " ~]#"? yes
expect: set expect_out(0,string) " ~]#"
expect: set expect_out(spawn_id) "exp6"
expect: set expect_out(buffer) " /root/config1.sh 1 2 3 1 1 2 3 2 1 2 3 3\r\n\u001b]0;root@localhost:~\u0007[root@localhost ~]#"
send: sending "/root/config2.sh\r" to { exp6 }

論壇徽章:
0
2 [報(bào)告]
發(fā)表于 2008-07-31 16:40 |只看該作者
參數(shù)傳遞的問(wèn)題已經(jīng)解決 !,F(xiàn)在就是不解。它為什么總是少執(zhí)行一條命令

論壇徽章:
0
3 [報(bào)告]
發(fā)表于 2008-07-31 18:30 |只看該作者
close 之前再加一句 expect " ~]#"
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專(zhuān)區(qū)
中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過(guò)ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP