嗨,这是我的期望脚本:
#!/usr/local/bin/expect -f
set force_conservative 0 ;# set to 1 to force conservative mode even if
;# script wasn't run conservatively originally
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}
set timeout -1
spawn $env(SHELL)
match_max 100000
send -- "ssh IP_addr\r"
expect -exact "password: "
send -- "something\r"
expect -exact "\r"
#expect -exact "Entering server port, ..... type ^z for port menu."
send -- "\r"
expect -exact "login: …Run Code Online (Sandbox Code Playgroud) 我将 ICMP“需要分段,设置 DF 位”注入服务器,理想情况下服务器应开始发送 ICMP 中“下一跳 MTU”字段中提到的大小的数据包。但这是行不通的。
这是服务器代码:
#!/usr/bin/env python
import socket # Import socket module
import time
import os
range= [1,2,3,4,5,6,7,8,9]
s = socket.socket() # Create a socket object
host = '192.168.0.17' # Get local machine name
port = 12349 # Reserve a port for your service.
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind((host, port)) # Bind to the port
rand_string = os.urandom(1600)
s.listen(5) # Now wait for client connection.
while True:
c, addr = s.accept() # Establish connection with client.
print …Run Code Online (Sandbox Code Playgroud) 我不知道如何使用expect发送箭头键,因此我为所有箭头键生成了autoexpect脚本,并发现autoexpect为右箭头键生成了这个字符:
send -- "^[\[C"
Run Code Online (Sandbox Code Playgroud)
我在自定义脚本中使用了相同的发送命令,但出现以下错误:
while executing
"send -- "^[\[C"
expect eof
"
(file "script_auto.exp" line 38)
Run Code Online (Sandbox Code Playgroud)
我到底该怎么做才能发送右箭头键。任何帮助,将不胜感激。