Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Shell 如何使用expect将输出变量写入字典或列表_Shell_Expect - Fatal编程技术网

Shell 如何使用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

我有一个expect脚本,它有一些从服务器提取并打印在屏幕上的输出值。如何使用expect将这些值写入映射到文件的列表或键值对?如果无法使用expect,我如何才能这样做,以及如何将我的脚本调用到另一个脚本中

登录到服务器后的脚本的一部分

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数据结构:或者(它们实际上是哈希,因为索引可以是字符串)或者