Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我有一个这样的 TCL 脚本:
exec ls -l
现在这将打印出当前目录的内容。我需要将该输出作为字符串进行解析。我怎么能做到这一点?
exec返回输出,因此只需为其设置一个变量:
exec
set result [exec ls -l]
但是,您可能希望将其包装在catch:
catch
if {[catch {exec ls -l} result] == 0} { # ... } else { # ... (error) }