Redirecting streams in bash shell - how to make unconditional on the rest of shell command line
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
1
down vote
favorite
I noted apt
output is different when executed alone in Bash shell and when output is redirected to files.
For example:
$ apt install ./*.deb --simulate 1>111.txt 2>222.txt
adding redirection results in text WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
in file for stream 2, whereas running apt w/out redirection does not display this text in shell window.
Why output depends on redirection? Maybe apt
sees redirection as its` parameter? How can I write redirection to be unnoticed to other part of shell command line?
P.S. I saw it in Ubuntu 18 and apt
is specific app, but maybe the issue is general to Unix, so I put only shell
in tag.
debian shell io-redirection
add a comment |Â
up vote
1
down vote
favorite
I noted apt
output is different when executed alone in Bash shell and when output is redirected to files.
For example:
$ apt install ./*.deb --simulate 1>111.txt 2>222.txt
adding redirection results in text WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
in file for stream 2, whereas running apt w/out redirection does not display this text in shell window.
Why output depends on redirection? Maybe apt
sees redirection as its` parameter? How can I write redirection to be unnoticed to other part of shell command line?
P.S. I saw it in Ubuntu 18 and apt
is specific app, but maybe the issue is general to Unix, so I put only shell
in tag.
debian shell io-redirection
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I noted apt
output is different when executed alone in Bash shell and when output is redirected to files.
For example:
$ apt install ./*.deb --simulate 1>111.txt 2>222.txt
adding redirection results in text WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
in file for stream 2, whereas running apt w/out redirection does not display this text in shell window.
Why output depends on redirection? Maybe apt
sees redirection as its` parameter? How can I write redirection to be unnoticed to other part of shell command line?
P.S. I saw it in Ubuntu 18 and apt
is specific app, but maybe the issue is general to Unix, so I put only shell
in tag.
debian shell io-redirection
I noted apt
output is different when executed alone in Bash shell and when output is redirected to files.
For example:
$ apt install ./*.deb --simulate 1>111.txt 2>222.txt
adding redirection results in text WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
in file for stream 2, whereas running apt w/out redirection does not display this text in shell window.
Why output depends on redirection? Maybe apt
sees redirection as its` parameter? How can I write redirection to be unnoticed to other part of shell command line?
P.S. I saw it in Ubuntu 18 and apt
is specific app, but maybe the issue is general to Unix, so I put only shell
in tag.
debian shell io-redirection
edited 2 days ago
slmâ¦
232k65479648
232k65479648
asked 2 days ago
Alexei Martianov
23211
23211
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
apt
has been designed historically with interactive command-line use in mind, hence the coded warning, which has been done on purpose in/by apt
and not by the shell.
However, apt
is not necessarily parsing the command line; the shell has already done that job by the time it calls apt
. What apt
is doing is detecting that the stdout
stream has been changed/redirected.
As for using apt
in scripts, you have got the similar older command apt-get
which does does more or less the same thing, and does not give that warning when stdout
is redirected.
TLDR Is not the shell writing the error message in stderr
, it is the apt
command.
The fact that you are able to capture the apt
stderr
output in the shell is an artifact of Unix being a multitasking OS, and does not mean it is the shell producing that output.
PS. Doing an strace at the command, it can be seen apt
writing that message:
strace apt get install bash > a
....
write(2, "n", 1
) = 1
write(2, "WARNING: ", 9WARNING: ) = 9
write(2, "apt", 3apt) = 3
write(2, " ", 1 ) = 1
write(2, "does not have a stable CLI inter"..., 38does not have a stable CLI interface. ) = 38
write(2, "Use with caution in scripts.", 28Use with caution in scripts.) = 28
write(2, "n", 1
) = 1
write(2, "n", 1
) = 1
Is there any way to prevent e.g. apt from detecting redirection?
â Alexei Martianov
2 days ago
1
The canonical way is using the equivalent tools likeapt-get
andapt-cache
. No switch/option to disable that behaviour that I know of.
â Rui F Ribeiro
2 days ago
What bothers me is not of cause that single additional phrase from apt, but the whole thing that when I see a long output in shell, I'd like to store it, do text search later, but cannot save it 100% the way it displays.
â Alexei Martianov
2 days ago
1
That is a whole different question actually. There is thescript
command for saving sessions of work.
â Rui F Ribeiro
2 days ago
script
is what I can use, thanx!
â Alexei Martianov
2 days ago
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
apt
has been designed historically with interactive command-line use in mind, hence the coded warning, which has been done on purpose in/by apt
and not by the shell.
However, apt
is not necessarily parsing the command line; the shell has already done that job by the time it calls apt
. What apt
is doing is detecting that the stdout
stream has been changed/redirected.
As for using apt
in scripts, you have got the similar older command apt-get
which does does more or less the same thing, and does not give that warning when stdout
is redirected.
TLDR Is not the shell writing the error message in stderr
, it is the apt
command.
The fact that you are able to capture the apt
stderr
output in the shell is an artifact of Unix being a multitasking OS, and does not mean it is the shell producing that output.
PS. Doing an strace at the command, it can be seen apt
writing that message:
strace apt get install bash > a
....
write(2, "n", 1
) = 1
write(2, "WARNING: ", 9WARNING: ) = 9
write(2, "apt", 3apt) = 3
write(2, " ", 1 ) = 1
write(2, "does not have a stable CLI inter"..., 38does not have a stable CLI interface. ) = 38
write(2, "Use with caution in scripts.", 28Use with caution in scripts.) = 28
write(2, "n", 1
) = 1
write(2, "n", 1
) = 1
Is there any way to prevent e.g. apt from detecting redirection?
â Alexei Martianov
2 days ago
1
The canonical way is using the equivalent tools likeapt-get
andapt-cache
. No switch/option to disable that behaviour that I know of.
â Rui F Ribeiro
2 days ago
What bothers me is not of cause that single additional phrase from apt, but the whole thing that when I see a long output in shell, I'd like to store it, do text search later, but cannot save it 100% the way it displays.
â Alexei Martianov
2 days ago
1
That is a whole different question actually. There is thescript
command for saving sessions of work.
â Rui F Ribeiro
2 days ago
script
is what I can use, thanx!
â Alexei Martianov
2 days ago
add a comment |Â
up vote
2
down vote
apt
has been designed historically with interactive command-line use in mind, hence the coded warning, which has been done on purpose in/by apt
and not by the shell.
However, apt
is not necessarily parsing the command line; the shell has already done that job by the time it calls apt
. What apt
is doing is detecting that the stdout
stream has been changed/redirected.
As for using apt
in scripts, you have got the similar older command apt-get
which does does more or less the same thing, and does not give that warning when stdout
is redirected.
TLDR Is not the shell writing the error message in stderr
, it is the apt
command.
The fact that you are able to capture the apt
stderr
output in the shell is an artifact of Unix being a multitasking OS, and does not mean it is the shell producing that output.
PS. Doing an strace at the command, it can be seen apt
writing that message:
strace apt get install bash > a
....
write(2, "n", 1
) = 1
write(2, "WARNING: ", 9WARNING: ) = 9
write(2, "apt", 3apt) = 3
write(2, " ", 1 ) = 1
write(2, "does not have a stable CLI inter"..., 38does not have a stable CLI interface. ) = 38
write(2, "Use with caution in scripts.", 28Use with caution in scripts.) = 28
write(2, "n", 1
) = 1
write(2, "n", 1
) = 1
Is there any way to prevent e.g. apt from detecting redirection?
â Alexei Martianov
2 days ago
1
The canonical way is using the equivalent tools likeapt-get
andapt-cache
. No switch/option to disable that behaviour that I know of.
â Rui F Ribeiro
2 days ago
What bothers me is not of cause that single additional phrase from apt, but the whole thing that when I see a long output in shell, I'd like to store it, do text search later, but cannot save it 100% the way it displays.
â Alexei Martianov
2 days ago
1
That is a whole different question actually. There is thescript
command for saving sessions of work.
â Rui F Ribeiro
2 days ago
script
is what I can use, thanx!
â Alexei Martianov
2 days ago
add a comment |Â
up vote
2
down vote
up vote
2
down vote
apt
has been designed historically with interactive command-line use in mind, hence the coded warning, which has been done on purpose in/by apt
and not by the shell.
However, apt
is not necessarily parsing the command line; the shell has already done that job by the time it calls apt
. What apt
is doing is detecting that the stdout
stream has been changed/redirected.
As for using apt
in scripts, you have got the similar older command apt-get
which does does more or less the same thing, and does not give that warning when stdout
is redirected.
TLDR Is not the shell writing the error message in stderr
, it is the apt
command.
The fact that you are able to capture the apt
stderr
output in the shell is an artifact of Unix being a multitasking OS, and does not mean it is the shell producing that output.
PS. Doing an strace at the command, it can be seen apt
writing that message:
strace apt get install bash > a
....
write(2, "n", 1
) = 1
write(2, "WARNING: ", 9WARNING: ) = 9
write(2, "apt", 3apt) = 3
write(2, " ", 1 ) = 1
write(2, "does not have a stable CLI inter"..., 38does not have a stable CLI interface. ) = 38
write(2, "Use with caution in scripts.", 28Use with caution in scripts.) = 28
write(2, "n", 1
) = 1
write(2, "n", 1
) = 1
apt
has been designed historically with interactive command-line use in mind, hence the coded warning, which has been done on purpose in/by apt
and not by the shell.
However, apt
is not necessarily parsing the command line; the shell has already done that job by the time it calls apt
. What apt
is doing is detecting that the stdout
stream has been changed/redirected.
As for using apt
in scripts, you have got the similar older command apt-get
which does does more or less the same thing, and does not give that warning when stdout
is redirected.
TLDR Is not the shell writing the error message in stderr
, it is the apt
command.
The fact that you are able to capture the apt
stderr
output in the shell is an artifact of Unix being a multitasking OS, and does not mean it is the shell producing that output.
PS. Doing an strace at the command, it can be seen apt
writing that message:
strace apt get install bash > a
....
write(2, "n", 1
) = 1
write(2, "WARNING: ", 9WARNING: ) = 9
write(2, "apt", 3apt) = 3
write(2, " ", 1 ) = 1
write(2, "does not have a stable CLI inter"..., 38does not have a stable CLI interface. ) = 38
write(2, "Use with caution in scripts.", 28Use with caution in scripts.) = 28
write(2, "n", 1
) = 1
write(2, "n", 1
) = 1
edited 2 days ago
answered 2 days ago
Rui F Ribeiro
33.3k1167112
33.3k1167112
Is there any way to prevent e.g. apt from detecting redirection?
â Alexei Martianov
2 days ago
1
The canonical way is using the equivalent tools likeapt-get
andapt-cache
. No switch/option to disable that behaviour that I know of.
â Rui F Ribeiro
2 days ago
What bothers me is not of cause that single additional phrase from apt, but the whole thing that when I see a long output in shell, I'd like to store it, do text search later, but cannot save it 100% the way it displays.
â Alexei Martianov
2 days ago
1
That is a whole different question actually. There is thescript
command for saving sessions of work.
â Rui F Ribeiro
2 days ago
script
is what I can use, thanx!
â Alexei Martianov
2 days ago
add a comment |Â
Is there any way to prevent e.g. apt from detecting redirection?
â Alexei Martianov
2 days ago
1
The canonical way is using the equivalent tools likeapt-get
andapt-cache
. No switch/option to disable that behaviour that I know of.
â Rui F Ribeiro
2 days ago
What bothers me is not of cause that single additional phrase from apt, but the whole thing that when I see a long output in shell, I'd like to store it, do text search later, but cannot save it 100% the way it displays.
â Alexei Martianov
2 days ago
1
That is a whole different question actually. There is thescript
command for saving sessions of work.
â Rui F Ribeiro
2 days ago
script
is what I can use, thanx!
â Alexei Martianov
2 days ago
Is there any way to prevent e.g. apt from detecting redirection?
â Alexei Martianov
2 days ago
Is there any way to prevent e.g. apt from detecting redirection?
â Alexei Martianov
2 days ago
1
1
The canonical way is using the equivalent tools like
apt-get
and apt-cache
. No switch/option to disable that behaviour that I know of.â Rui F Ribeiro
2 days ago
The canonical way is using the equivalent tools like
apt-get
and apt-cache
. No switch/option to disable that behaviour that I know of.â Rui F Ribeiro
2 days ago
What bothers me is not of cause that single additional phrase from apt, but the whole thing that when I see a long output in shell, I'd like to store it, do text search later, but cannot save it 100% the way it displays.
â Alexei Martianov
2 days ago
What bothers me is not of cause that single additional phrase from apt, but the whole thing that when I see a long output in shell, I'd like to store it, do text search later, but cannot save it 100% the way it displays.
â Alexei Martianov
2 days ago
1
1
That is a whole different question actually. There is the
script
command for saving sessions of work.â Rui F Ribeiro
2 days ago
That is a whole different question actually. There is the
script
command for saving sessions of work.â Rui F Ribeiro
2 days ago
script
is what I can use, thanx!â Alexei Martianov
2 days ago
script
is what I can use, thanx!â Alexei Martianov
2 days ago
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%2f460503%2fredirecting-streams-in-bash-shell-how-to-make-unconditional-on-the-rest-of-she%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