我在那里有五个琴弦:
proc send_command_to_SSH {ssh_stream_id command} {
while {1} {
#tried to use this flush even here
flush stdout
puts $ssh_stream_id "$command"
#tried here also
flush $ssh_stream_id
flush stdout
set L [gets $ssh_stream_id OutPut]
if {$OutPut != ""} {
puts "$OutPut \n"
incr number_of_lines_sent_to_xsl 1
if {[regexp ".*194:" $OutPut]== 1} {
return "Done"
}
}
}
}
To execute the above procs I am executing the following commands:
set a [open_ssh_connection]
set b [send_command_to_SSH $a "stack_mgr_cli" "xsl" 2]
set c [send_command_to_SSH $a "exit" "xsl" 2]
the output of "set a [open_ssh_connection]" is:
file38900e0
the output of "set b [send_command_to_SSH $a "stack_mgr_cli" "xsl" 2]" is:
More commands:
stack_mgr --help
stack_mgr@ip-172-32-43-194:~$
16
(Call Generator) 53 % Just as expected .
The output of "set c [send_command_to_SSH $a "exit"]""
expected : send command "exit" to the shell , and exit the above process.
actual : (Call Generator) 53 % set c [send_command_to_SSH $a "exit"]
$ $ stack_mgr_cli
-su: stack_mgr_cli: command not found
stack_mgr@ip-172-32-43-194:~$
如何提取字符串列表中的这些数字?
答案 0 :(得分:0)
使用map函数(在Python 2.x中):
https://docs.python.org/2/library/functions.html#map
some_ids = [1, 2, 3, 4, 5]
string_list = map(str, some_ids)
或者在Python 3中,您需要将结果从map转换为列表: https://docs.python.org/3/library/functions.html#map
string_list = list(map(str, some_ids))