Shell 如何使用expect将输出变量写入字典或列表
我有一个expect脚本,它有一些从服务器提取并打印在屏幕上的输出值。如何使用expect将这些值写入映射到文件的列表或键值对?如果无法使用expect,我如何才能这样做,以及如何将我的脚本调用到另一个脚本中 登录到服务器后的脚本的一部分Shell 如何使用expect将输出变量写入字典或列表,shell,expect,Shell,Expect,我有一个expect脚本,它有一些从服务器提取并打印在屏幕上的输出值。如何使用expect将这些值写入映射到文件的列表或键值对?如果无法使用expect,我如何才能这样做,以及如何将我的脚本调用到另一个脚本中 登录到服务器后的脚本的一部分 send "menu\r" expect "*:*" regexp {.*(Name.*)(Path.*)(State.*)} $expect_out(buffer) matched op1 op2 op3 #puts \n send_user "Name i
send "menu\r"
expect "*:*"
regexp {.*(Name.*)(Path.*)(State.*)} $expect_out(buffer) matched op1 op2 op3
#puts \n
send_user "Name is: "
puts [string trim $op1]
send_user "Path is: "
puts [string trim $op2]
send_user "State is: "
puts [string trim $op3]
因此,对于输出变量
$op1
,$op2
,$op3
如何将它们的值存储到列表或字典中?可以使用任何TCL数据结构:或者(它们实际上是哈希,因为索引可以是字符串)或者