alexlipa
alexlipa

Reputation: 1291

how to redirect stdout and stderr of a called script to the same values of the caller?

I have a script a.sh which does this

args="--conf myconf=2"
/usr/bin/b.sh $args

when I do this, I don't see anymore the stdout of b.sh. Also, I would like to be able to redirect b.sh stdout and stderr to the same values specified for a.sh, for example if a user calls a.sh 1> out.txt 2> err.txt I want to see the stdout of b.sh in out.txt and the stderr of b.sh in err.txt

Upvotes: 0

Views: 90

Answers (1)

Diego Torres Milano
Diego Torres Milano

Reputation: 69396

If in doubt of what's happening with the redirection, add this to you b.sh script

#! /bin/bash
lsof -d 0,1,2 -a -p $$
...

and you can check where the FD's 0,1 and 2 are redirected.

Upvotes: 1

Related Questions