Hi How to redirect the output of exec

Hi

Here i have a script a

#!/usr/bin/env tclsh

puts "Hello World!"
set filename "./BesRun.sh"

[exec $filename ] > out.txt

exit

I am trying to redirect the output of the "./BesRun.sh" to out.txt,but it is not happening can anyone let me know

I've been not able to run
[exec ...

  • the [exec is assumed a command.
    Do you mean to have a space?
    Also I do not see a reason for '[ ]'
    Without that output is written.
    Are you awared that after 'exec' you do not executing any line from current script as it replaces the current script with executed one: $filename?

But I am not shure about your start line - why and what you have done by that. Maybe it makes a difference

I'm not overtly familiar with TCL, and you should probably mention which language you are dealing with (witness Alex' confusion above).

AlternativeToExec suggests that this is not really possible, but also provides a number of (ugly) workarounds.