Search code examples
rubyperltclbackticks

Does Tcl have an equivalent of PERL and Ruby backtic


In Ruby/PERL, I can very easily get the console output of a system command fed into a file. For example:

$k = `ls`

Would input the output of ls into variable $k in PERL (and Ruby).
How can one do something like this in Tcl?
Thanks


Solution

  • Use exec command to get the same.

    set output [ exec ls ]
    puts $output
    

    Man page : exec