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 7654177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:12:39+00:00 2026-05-31T12:12:39+00:00

I need to run this linux command from python and assign the output to

  • 0

I need to run this linux command from python and assign the output to a variable.

ps -ef | grep rtptransmit | grep -v grep

I’ve tried using pythons commands library to do this.

import commands
a = commands.getoutput('ps -ef | grep rtptransmit | grep -v grep')

But a gets the end of cut off. The output I get is:

'nvr      20714 20711  0 10:39 ?        00:00:00 /opt/americandynamics/venvr/bin/rtptransmit setup_req db=media  camera=6  stream=video  substream=1  client_a'

but the expected output is:

nvr      20714 20711  0 10:39 ?        00:00:00 /opt/americandynamics/venvr/bin/rtptransmit setup_req db=media  camera=6  stream=video  substream=1  client_address=192.168.200.179  client_rtp_port=6970  override_lockout=1  clienttype=1

Does anyone know how to stop the output from getting cut off or can anyone suggest another method?

  • 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-05-31T12:12:40+00:00Added an answer on May 31, 2026 at 12:12 pm

    ps apparently limits its output to fit into the presumed width of the terminal. You can override this width with the $COLUMNS environment variable or with the --columns option to ps.

    The commands module is deprecated. Use subprocess to get the output of ps -ef and filter the output in Python. Do not use shell=True as suggested by other answers, it is simply superfluous in this case:

    ps = subprocess.Popen(['ps', '-ef', '--columns', '1000'], stdout=subprocess.PIPE)
    output = ps.communicate()[0]
    for line in output.splitlines():
        if 'rtptransmit' in line:
            print(line)
    

    You may also want to take a look the pgrep command by which you can directly search for specific processes.

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

Sidebar

Related Questions

I need to run a Linux CLI command and get its stdout output from
I need to run a linux command such as df from my linux daemon
I need to run this line from my c++ program: java -jar test.jar text1
I seem to run into this very often. I need to build a Hash
I have a statement similar to this that I need to run in Linq.
For reasons that are irrelevant to this question I'll need to run several SQLite
This seems like it should be something I already know. We need to run
I need to run a stored procedure from a C# application. I use the
I'd like to prevent multiple instances of the same long-running python command-line script from
I'm debugging an ANSI C program run on 64-bit Linux CentOS 5.7 using gcc44

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.