apt gives “Unstable CLI Interface” warning
I am writing a script that needs to read a file containing information of a package for which I wrote this line
apt show $PACKAGE_NAME > pack_info.txt
However this doesn't creates the pack_info.txt
file and always gives this Warning :
WARNING : apt does not have a stable CLI interface. Use with caution in scripts.
For the time being I tried redirecting both STDOUT
& STDERR
using &>
and it worked out to give a file pack_info.txt
that we need.
I also tried getting contents from dpkg
and that also worked :
dpkg -s $PACKAGE_NAME > pack_info.txt
What is good that it neither shows a warning nor an error.
What is bad that we don't want to use dpkg and only want STDOUT of apt to redirect to file.
So, I have three Questions to ask :
- What do we exactly mean by Stable CLI Interface ?
- How to safely and error-free use such commands in scripts ?
[please care to explain with example] - Is there a way to only and only redirect STDOUT of
apt show
to a file ?
command-line apt package-management
add a comment |
I am writing a script that needs to read a file containing information of a package for which I wrote this line
apt show $PACKAGE_NAME > pack_info.txt
However this doesn't creates the pack_info.txt
file and always gives this Warning :
WARNING : apt does not have a stable CLI interface. Use with caution in scripts.
For the time being I tried redirecting both STDOUT
& STDERR
using &>
and it worked out to give a file pack_info.txt
that we need.
I also tried getting contents from dpkg
and that also worked :
dpkg -s $PACKAGE_NAME > pack_info.txt
What is good that it neither shows a warning nor an error.
What is bad that we don't want to use dpkg and only want STDOUT of apt to redirect to file.
So, I have three Questions to ask :
- What do we exactly mean by Stable CLI Interface ?
- How to safely and error-free use such commands in scripts ?
[please care to explain with example] - Is there a way to only and only redirect STDOUT of
apt show
to a file ?
command-line apt package-management
add a comment |
I am writing a script that needs to read a file containing information of a package for which I wrote this line
apt show $PACKAGE_NAME > pack_info.txt
However this doesn't creates the pack_info.txt
file and always gives this Warning :
WARNING : apt does not have a stable CLI interface. Use with caution in scripts.
For the time being I tried redirecting both STDOUT
& STDERR
using &>
and it worked out to give a file pack_info.txt
that we need.
I also tried getting contents from dpkg
and that also worked :
dpkg -s $PACKAGE_NAME > pack_info.txt
What is good that it neither shows a warning nor an error.
What is bad that we don't want to use dpkg and only want STDOUT of apt to redirect to file.
So, I have three Questions to ask :
- What do we exactly mean by Stable CLI Interface ?
- How to safely and error-free use such commands in scripts ?
[please care to explain with example] - Is there a way to only and only redirect STDOUT of
apt show
to a file ?
command-line apt package-management
I am writing a script that needs to read a file containing information of a package for which I wrote this line
apt show $PACKAGE_NAME > pack_info.txt
However this doesn't creates the pack_info.txt
file and always gives this Warning :
WARNING : apt does not have a stable CLI interface. Use with caution in scripts.
For the time being I tried redirecting both STDOUT
& STDERR
using &>
and it worked out to give a file pack_info.txt
that we need.
I also tried getting contents from dpkg
and that also worked :
dpkg -s $PACKAGE_NAME > pack_info.txt
What is good that it neither shows a warning nor an error.
What is bad that we don't want to use dpkg and only want STDOUT of apt to redirect to file.
So, I have three Questions to ask :
- What do we exactly mean by Stable CLI Interface ?
- How to safely and error-free use such commands in scripts ?
[please care to explain with example] - Is there a way to only and only redirect STDOUT of
apt show
to a file ?
command-line apt package-management
command-line apt package-management
edited Dec 30 '17 at 15:27
dessert
22.3k56198
22.3k56198
asked Dec 30 '17 at 14:28
C0deDaedalusC0deDaedalus
3312416
3312416
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
apt
is for the terminal and gives beautiful output while apt-get
and apt-cache
are for scripts and give stable, parseable output. The script equivalent of your apt show
command therefore is:
apt-cache show $PACKAGE_NAME >pack_info.txt
Now to answer your questions one by one:
What do we exactly mean by Stable CLI Interface?
apt
's output is not well useable in scripts. For example, apt install
(compared to apt-get install
) displays a progress bar that's useless for scripts and can throw errors when the output is parsed. apt show firefox
shows a hint for an additional record, which is also totally useless in a script, you want it to simply output every record there – that's what apt-cache show firefox
does. Let's see what man apt
has to say about that:
The apt(8) commandline is designed as an end-user tool and it may
change behavior between versions. While it
tries not to break backward compatibility this is not guaranteed either if a change seems beneficial for
interactive use.
All features of apt(8) are available in dedicated APT tools like apt-get(8) and apt-cache(8) as well. apt(8)
just changes the default value of some options (see apt.conf(5) and specifically the Binary scope). So you
should prefer using these commands (potentially with some additional options enabled) in your scripts as they
keep backward compatibility as much as possible.
How to safely and error-free use such commands in scripts?
Just use apt-get
or apt-cache
respectively instead of plain apt
. :) See this answer for a list of equivalents.
Is there a way to only and only redirect STDOUT of apt show to a file?
You did that correctly already: >file
or 1>file
redirects stdout, 2>file
redirects stderr and &>file
redirects both to file
.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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%2faskubuntu.com%2fquestions%2f990823%2fapt-gives-unstable-cli-interface-warning%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
apt
is for the terminal and gives beautiful output while apt-get
and apt-cache
are for scripts and give stable, parseable output. The script equivalent of your apt show
command therefore is:
apt-cache show $PACKAGE_NAME >pack_info.txt
Now to answer your questions one by one:
What do we exactly mean by Stable CLI Interface?
apt
's output is not well useable in scripts. For example, apt install
(compared to apt-get install
) displays a progress bar that's useless for scripts and can throw errors when the output is parsed. apt show firefox
shows a hint for an additional record, which is also totally useless in a script, you want it to simply output every record there – that's what apt-cache show firefox
does. Let's see what man apt
has to say about that:
The apt(8) commandline is designed as an end-user tool and it may
change behavior between versions. While it
tries not to break backward compatibility this is not guaranteed either if a change seems beneficial for
interactive use.
All features of apt(8) are available in dedicated APT tools like apt-get(8) and apt-cache(8) as well. apt(8)
just changes the default value of some options (see apt.conf(5) and specifically the Binary scope). So you
should prefer using these commands (potentially with some additional options enabled) in your scripts as they
keep backward compatibility as much as possible.
How to safely and error-free use such commands in scripts?
Just use apt-get
or apt-cache
respectively instead of plain apt
. :) See this answer for a list of equivalents.
Is there a way to only and only redirect STDOUT of apt show to a file?
You did that correctly already: >file
or 1>file
redirects stdout, 2>file
redirects stderr and &>file
redirects both to file
.
add a comment |
apt
is for the terminal and gives beautiful output while apt-get
and apt-cache
are for scripts and give stable, parseable output. The script equivalent of your apt show
command therefore is:
apt-cache show $PACKAGE_NAME >pack_info.txt
Now to answer your questions one by one:
What do we exactly mean by Stable CLI Interface?
apt
's output is not well useable in scripts. For example, apt install
(compared to apt-get install
) displays a progress bar that's useless for scripts and can throw errors when the output is parsed. apt show firefox
shows a hint for an additional record, which is also totally useless in a script, you want it to simply output every record there – that's what apt-cache show firefox
does. Let's see what man apt
has to say about that:
The apt(8) commandline is designed as an end-user tool and it may
change behavior between versions. While it
tries not to break backward compatibility this is not guaranteed either if a change seems beneficial for
interactive use.
All features of apt(8) are available in dedicated APT tools like apt-get(8) and apt-cache(8) as well. apt(8)
just changes the default value of some options (see apt.conf(5) and specifically the Binary scope). So you
should prefer using these commands (potentially with some additional options enabled) in your scripts as they
keep backward compatibility as much as possible.
How to safely and error-free use such commands in scripts?
Just use apt-get
or apt-cache
respectively instead of plain apt
. :) See this answer for a list of equivalents.
Is there a way to only and only redirect STDOUT of apt show to a file?
You did that correctly already: >file
or 1>file
redirects stdout, 2>file
redirects stderr and &>file
redirects both to file
.
add a comment |
apt
is for the terminal and gives beautiful output while apt-get
and apt-cache
are for scripts and give stable, parseable output. The script equivalent of your apt show
command therefore is:
apt-cache show $PACKAGE_NAME >pack_info.txt
Now to answer your questions one by one:
What do we exactly mean by Stable CLI Interface?
apt
's output is not well useable in scripts. For example, apt install
(compared to apt-get install
) displays a progress bar that's useless for scripts and can throw errors when the output is parsed. apt show firefox
shows a hint for an additional record, which is also totally useless in a script, you want it to simply output every record there – that's what apt-cache show firefox
does. Let's see what man apt
has to say about that:
The apt(8) commandline is designed as an end-user tool and it may
change behavior between versions. While it
tries not to break backward compatibility this is not guaranteed either if a change seems beneficial for
interactive use.
All features of apt(8) are available in dedicated APT tools like apt-get(8) and apt-cache(8) as well. apt(8)
just changes the default value of some options (see apt.conf(5) and specifically the Binary scope). So you
should prefer using these commands (potentially with some additional options enabled) in your scripts as they
keep backward compatibility as much as possible.
How to safely and error-free use such commands in scripts?
Just use apt-get
or apt-cache
respectively instead of plain apt
. :) See this answer for a list of equivalents.
Is there a way to only and only redirect STDOUT of apt show to a file?
You did that correctly already: >file
or 1>file
redirects stdout, 2>file
redirects stderr and &>file
redirects both to file
.
apt
is for the terminal and gives beautiful output while apt-get
and apt-cache
are for scripts and give stable, parseable output. The script equivalent of your apt show
command therefore is:
apt-cache show $PACKAGE_NAME >pack_info.txt
Now to answer your questions one by one:
What do we exactly mean by Stable CLI Interface?
apt
's output is not well useable in scripts. For example, apt install
(compared to apt-get install
) displays a progress bar that's useless for scripts and can throw errors when the output is parsed. apt show firefox
shows a hint for an additional record, which is also totally useless in a script, you want it to simply output every record there – that's what apt-cache show firefox
does. Let's see what man apt
has to say about that:
The apt(8) commandline is designed as an end-user tool and it may
change behavior between versions. While it
tries not to break backward compatibility this is not guaranteed either if a change seems beneficial for
interactive use.
All features of apt(8) are available in dedicated APT tools like apt-get(8) and apt-cache(8) as well. apt(8)
just changes the default value of some options (see apt.conf(5) and specifically the Binary scope). So you
should prefer using these commands (potentially with some additional options enabled) in your scripts as they
keep backward compatibility as much as possible.
How to safely and error-free use such commands in scripts?
Just use apt-get
or apt-cache
respectively instead of plain apt
. :) See this answer for a list of equivalents.
Is there a way to only and only redirect STDOUT of apt show to a file?
You did that correctly already: >file
or 1>file
redirects stdout, 2>file
redirects stderr and &>file
redirects both to file
.
edited Dec 23 '18 at 19:43
answered Dec 30 '17 at 15:15
dessertdessert
22.3k56198
22.3k56198
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- 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%2faskubuntu.com%2fquestions%2f990823%2fapt-gives-unstable-cli-interface-warning%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