Eric415 wrote:
> separate file specified along with the command. For some reason, when I run
> the master script using nohup [...] each of the commands redirects their
> output to nohup.out instead of the specified file. Any ideas?

The nohup command redirects output to the nohup.out file if the output
is a terminal.  Because it redirected to nohup.out we know that the
output was a terminal at that point and that your attempt at
redirection had failed.

> nohup nice prog1 &> prog1.out
> ${commands[ran]} &

Why has your redirection failed?  Because redirections are processed
before variable expansion.  Because your redirection is included in
the variable which is expanded the redirection is too late.  That is
why it wasn't working.

This can be demonstrated with:

  $ x='>/tmp/out'
  $ echo hello $x
  hello >/tmp/out

Solution?  One way is to add an eval.

  $ eval echo hello $x

And similarly for your case:

  eval ${commands[ran]} &

This will process redirections, expand variables, then run the eval
which will do it all again and on the second pass handle the newly
appearing redirections that results from the previous variable
expansion.

Bob


Reply via email to