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) }