Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8196467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:29:16+00:00 2026-06-07T05:29:16+00:00

Since the commands module is deprecated since Python 2.6, I’m looking into the best

  • 0

Since the commands module is deprecated since Python 2.6, I’m looking into the best way to replace commands.getstatusoutput which returns a tuple of the command’s return code and output. The subprocess module is rather obvious, however, it doesn’t offer a direct replacement for getstatusoutput. A potential solution is discussed in a related question concerning getstatusoutput – however, I’m not looking into rewriting the original function (which has less then 10 LOC anyway) but would like to know if there is a more straightforward way.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T05:29:18+00:00Added an answer on June 7, 2026 at 5:29 am

    There is no direct replacement, because commands.getstatusoutput was a bad API; it combines stderr and stdout without giving an option to retrieve them separately.

    The convenience API that you should be using is subprocess.check_output as it will throw an exception if the command fails.

    Otherwise, it does appear somewhat of a deficiency that subprocess doesn’t provide a method to retrieve output and status in a single call, but it’s easy to work around; here’s what the answer to the linked question should have been:

    def get_status_output(*args, **kwargs):
        p = subprocess.Popen(*args, **kwargs)
        stdout, stderr = p.communicate()
        return p.returncode, stdout, stderr
    

    If you want stdout and stderr together, use stderr=subprocess.STDOUT.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a python based tkinter script which executes some commands using subprocess module.
I currently have an implementation using the pexpect python module, which interacts with Juniper,
Since now I have only used plugin for editing and the way I use
I have Karmic Koala which has Python 2.6 installed by default. However I can't
I'm writing a Python program with a GUI built with the Tkinter module. I'm
I'm writing a script that uses a series of complex Imagemagick commands in python.
I am having trouble with the Python multiprocessing module. I am using the Process
I would like to write an OCaml module having a compile function which will
I'm currently building a program in C# which will call functions in provided python
Is there a module written purely in Python that will allow a script to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.