What's the purpose of 1> in exec 1> >(logger -s -t tagname) 2>&1?
I just stumbled over
exec 1> >(logger -s -t $(basename $0)) 2>&1
which is used to redirect the output of the current script to the system logger (in case you've never seen this, but are interested check out https://stackoverflow.com/questions/8888251/understanding-bash-exec-12-command to broaden your shell knowledge).
I am wondering why the 1>
is necessary. It seems necessary because exec >(logger -s -t test) 2>&1
fails due to
bash: /dev/fd/63: Permission denied
bash: exec: /dev/fd/63: cannot execute: Permission denied
Omitting 1>
is however what I'd do intuitively because exec >[some redirection target]
already should be sufficient for the redirection according to the question linked above. 2>&1
then redirects the stderr to stdout as usual.
I'm using bash 4.4.19.
bash shell io-redirection exec
add a comment |
I just stumbled over
exec 1> >(logger -s -t $(basename $0)) 2>&1
which is used to redirect the output of the current script to the system logger (in case you've never seen this, but are interested check out https://stackoverflow.com/questions/8888251/understanding-bash-exec-12-command to broaden your shell knowledge).
I am wondering why the 1>
is necessary. It seems necessary because exec >(logger -s -t test) 2>&1
fails due to
bash: /dev/fd/63: Permission denied
bash: exec: /dev/fd/63: cannot execute: Permission denied
Omitting 1>
is however what I'd do intuitively because exec >[some redirection target]
already should be sufficient for the redirection according to the question linked above. 2>&1
then redirects the stderr to stdout as usual.
I'm using bash 4.4.19.
bash shell io-redirection exec
It is necessary (the extra>
, not the1
,1>
could be simply written>
). The>(...)
process substitution will expand to something like/dev/fd/13
(a file name), and then>
will redirect the standard output into it. Thence> >(...)
.
– mosvy
38 mins ago
@mosvy I see, thank you. I just learned about process substitution, i.e. didn't know that>(...)
means that. I'd accept that as an answer.
– Karl Richter
30 mins ago
add a comment |
I just stumbled over
exec 1> >(logger -s -t $(basename $0)) 2>&1
which is used to redirect the output of the current script to the system logger (in case you've never seen this, but are interested check out https://stackoverflow.com/questions/8888251/understanding-bash-exec-12-command to broaden your shell knowledge).
I am wondering why the 1>
is necessary. It seems necessary because exec >(logger -s -t test) 2>&1
fails due to
bash: /dev/fd/63: Permission denied
bash: exec: /dev/fd/63: cannot execute: Permission denied
Omitting 1>
is however what I'd do intuitively because exec >[some redirection target]
already should be sufficient for the redirection according to the question linked above. 2>&1
then redirects the stderr to stdout as usual.
I'm using bash 4.4.19.
bash shell io-redirection exec
I just stumbled over
exec 1> >(logger -s -t $(basename $0)) 2>&1
which is used to redirect the output of the current script to the system logger (in case you've never seen this, but are interested check out https://stackoverflow.com/questions/8888251/understanding-bash-exec-12-command to broaden your shell knowledge).
I am wondering why the 1>
is necessary. It seems necessary because exec >(logger -s -t test) 2>&1
fails due to
bash: /dev/fd/63: Permission denied
bash: exec: /dev/fd/63: cannot execute: Permission denied
Omitting 1>
is however what I'd do intuitively because exec >[some redirection target]
already should be sufficient for the redirection according to the question linked above. 2>&1
then redirects the stderr to stdout as usual.
I'm using bash 4.4.19.
bash shell io-redirection exec
bash shell io-redirection exec
asked 41 mins ago
Karl Richter
7521823
7521823
It is necessary (the extra>
, not the1
,1>
could be simply written>
). The>(...)
process substitution will expand to something like/dev/fd/13
(a file name), and then>
will redirect the standard output into it. Thence> >(...)
.
– mosvy
38 mins ago
@mosvy I see, thank you. I just learned about process substitution, i.e. didn't know that>(...)
means that. I'd accept that as an answer.
– Karl Richter
30 mins ago
add a comment |
It is necessary (the extra>
, not the1
,1>
could be simply written>
). The>(...)
process substitution will expand to something like/dev/fd/13
(a file name), and then>
will redirect the standard output into it. Thence> >(...)
.
– mosvy
38 mins ago
@mosvy I see, thank you. I just learned about process substitution, i.e. didn't know that>(...)
means that. I'd accept that as an answer.
– Karl Richter
30 mins ago
It is necessary (the extra
>
, not the 1
, 1>
could be simply written >
). The >(...)
process substitution will expand to something like /dev/fd/13
(a file name), and then >
will redirect the standard output into it. Thence > >(...)
.– mosvy
38 mins ago
It is necessary (the extra
>
, not the 1
, 1>
could be simply written >
). The >(...)
process substitution will expand to something like /dev/fd/13
(a file name), and then >
will redirect the standard output into it. Thence > >(...)
.– mosvy
38 mins ago
@mosvy I see, thank you. I just learned about process substitution, i.e. didn't know that
>(...)
means that. I'd accept that as an answer.– Karl Richter
30 mins ago
@mosvy I see, thank you. I just learned about process substitution, i.e. didn't know that
>(...)
means that. I'd accept that as an answer.– Karl Richter
30 mins ago
add a comment |
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f491274%2fwhats-the-purpose-of-1-in-exec-1-logger-s-t-tagname-21%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f491274%2fwhats-the-purpose-of-1-in-exec-1-logger-s-t-tagname-21%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
It is necessary (the extra
>
, not the1
,1>
could be simply written>
). The>(...)
process substitution will expand to something like/dev/fd/13
(a file name), and then>
will redirect the standard output into it. Thence> >(...)
.– mosvy
38 mins ago
@mosvy I see, thank you. I just learned about process substitution, i.e. didn't know that
>(...)
means that. I'd accept that as an answer.– Karl Richter
30 mins ago