Change stdout/stderr output device
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
By default if we run
foo()
echo "myfoo"
it will go to stdout. My question is, for a bash script or function, is there a programmatic way to change the device so that commands don't automatically write to stdout?
maybe something like this:
foo()
mkfifo bar
exec 1<>bar
echo "myfoo" # this gets written to the bar named pipe?
so we "repoint" stdout somewhere else perhaps?
bash shell stdout file-descriptors exec
add a comment |Â
up vote
0
down vote
favorite
By default if we run
foo()
echo "myfoo"
it will go to stdout. My question is, for a bash script or function, is there a programmatic way to change the device so that commands don't automatically write to stdout?
maybe something like this:
foo()
mkfifo bar
exec 1<>bar
echo "myfoo" # this gets written to the bar named pipe?
so we "repoint" stdout somewhere else perhaps?
bash shell stdout file-descriptors exec
yeah that doesn't seem to work. If i runtail -f bar
I don't seem to get any data there.
â Alexander Mills
May 8 at 4:40
Are you asking for something very different fromfoo >bar
?
â Kusalananda
May 8 at 4:58
@Kusalananda honestly, I might delete this question, this new question is better: unix.stackexchange.com/questions/442461/â¦
â Alexander Mills
May 8 at 4:59
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
By default if we run
foo()
echo "myfoo"
it will go to stdout. My question is, for a bash script or function, is there a programmatic way to change the device so that commands don't automatically write to stdout?
maybe something like this:
foo()
mkfifo bar
exec 1<>bar
echo "myfoo" # this gets written to the bar named pipe?
so we "repoint" stdout somewhere else perhaps?
bash shell stdout file-descriptors exec
By default if we run
foo()
echo "myfoo"
it will go to stdout. My question is, for a bash script or function, is there a programmatic way to change the device so that commands don't automatically write to stdout?
maybe something like this:
foo()
mkfifo bar
exec 1<>bar
echo "myfoo" # this gets written to the bar named pipe?
so we "repoint" stdout somewhere else perhaps?
bash shell stdout file-descriptors exec
asked May 8 at 4:36
Alexander Mills
1,885929
1,885929
yeah that doesn't seem to work. If i runtail -f bar
I don't seem to get any data there.
â Alexander Mills
May 8 at 4:40
Are you asking for something very different fromfoo >bar
?
â Kusalananda
May 8 at 4:58
@Kusalananda honestly, I might delete this question, this new question is better: unix.stackexchange.com/questions/442461/â¦
â Alexander Mills
May 8 at 4:59
add a comment |Â
yeah that doesn't seem to work. If i runtail -f bar
I don't seem to get any data there.
â Alexander Mills
May 8 at 4:40
Are you asking for something very different fromfoo >bar
?
â Kusalananda
May 8 at 4:58
@Kusalananda honestly, I might delete this question, this new question is better: unix.stackexchange.com/questions/442461/â¦
â Alexander Mills
May 8 at 4:59
yeah that doesn't seem to work. If i run
tail -f bar
I don't seem to get any data there.â Alexander Mills
May 8 at 4:40
yeah that doesn't seem to work. If i run
tail -f bar
I don't seem to get any data there.â Alexander Mills
May 8 at 4:40
Are you asking for something very different from
foo >bar
?â Kusalananda
May 8 at 4:58
Are you asking for something very different from
foo >bar
?â Kusalananda
May 8 at 4:58
@Kusalananda honestly, I might delete this question, this new question is better: unix.stackexchange.com/questions/442461/â¦
â Alexander Mills
May 8 at 4:59
@Kusalananda honestly, I might delete this question, this new question is better: unix.stackexchange.com/questions/442461/â¦
â Alexander Mills
May 8 at 4:59
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
This technique will probably do the trick:
Using process substitution, only send stderr to process
Basically, you call:
exec > $some_file
using process substitution, you can do something like:
exec > >( while read line; do echo " stdout: $line"; done )
that means that all stdout will go to that file instead of to the terminal.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
This technique will probably do the trick:
Using process substitution, only send stderr to process
Basically, you call:
exec > $some_file
using process substitution, you can do something like:
exec > >( while read line; do echo " stdout: $line"; done )
that means that all stdout will go to that file instead of to the terminal.
add a comment |Â
up vote
0
down vote
This technique will probably do the trick:
Using process substitution, only send stderr to process
Basically, you call:
exec > $some_file
using process substitution, you can do something like:
exec > >( while read line; do echo " stdout: $line"; done )
that means that all stdout will go to that file instead of to the terminal.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
This technique will probably do the trick:
Using process substitution, only send stderr to process
Basically, you call:
exec > $some_file
using process substitution, you can do something like:
exec > >( while read line; do echo " stdout: $line"; done )
that means that all stdout will go to that file instead of to the terminal.
This technique will probably do the trick:
Using process substitution, only send stderr to process
Basically, you call:
exec > $some_file
using process substitution, you can do something like:
exec > >( while read line; do echo " stdout: $line"; done )
that means that all stdout will go to that file instead of to the terminal.
answered May 8 at 4:50
Alexander Mills
1,885929
1,885929
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f442460%2fchange-stdout-stderr-output-device%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
yeah that doesn't seem to work. If i run
tail -f bar
I don't seem to get any data there.â Alexander Mills
May 8 at 4:40
Are you asking for something very different from
foo >bar
?â Kusalananda
May 8 at 4:58
@Kusalananda honestly, I might delete this question, this new question is better: unix.stackexchange.com/questions/442461/â¦
â Alexander Mills
May 8 at 4:59